~widelands-dev/widelands/trunk

« back to all changes in this revision

Viewing changes to src/logic/game.cc

  • Committer: Wideland's Bunnybot
  • Date: 2018-11-23 08:20:36 UTC
  • mfrom: (8895.4.5 catching-fs-errors)
  • Revision ID: bunnybot@widelands.org-20181123082036-4nyz8m70wexsj1xq
Merged lp:~widelands-dev/widelands/handling-various-fs-errors:
Improved error handling for file save dialogs

In Load/Save menu for games/replays:
- All deletion errors are caught, player gets a message.
- When deleting multiplayer replays, also the corresponding syncstream file is deleted.
- After deleting replays, the table now respects the Show Filenames setting.

In Save menu for maps:
- Errors when trying to create a directory are now caught, player gets a message.
- Directory creation now doesn't allow names with map extensions, because the game would just trying to interpret them as maps and not show as directories. A tooltip is shown.
- Directory creation can now also be triggered by pressing Enter in the name edit box.

Other file errors are caught and logged:
- syncstream deletion in SyncWrapper destructor
- in Map::get_correct_loader
- file deletion/renaming in GameClient::handle_packet

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
Game::SyncWrapper::~SyncWrapper() {
76
76
        if (dump_ != nullptr) {
77
77
                if (!syncstreamsave_)
78
 
                        g_fs->fs_unlink(dumpfname_);
 
78
                        try {
 
79
                                g_fs->fs_unlink(dumpfname_);
 
80
                        } catch (const FileError& e) {
 
81
                                // not really a problem if deletion fails, but we'll log it
 
82
                                log("Deleting synchstream file %s failed: %s\n", dumpfname_.c_str(), e.what());
 
83
                        }
79
84
        }
80
85
}
81
86