1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 23:23:52 +00:00

Handle failed savegame file operations (Fixes #1413)

This commit is contained in:
scrawl 2014-06-07 17:48:40 +02:00
parent 2ec324c80b
commit b470596206

View file

@ -233,6 +233,9 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
writer.close(); writer.close();
if (stream.fail())
throw std::runtime_error("Write operation failed");
Settings::Manager::setString ("character", "Saves", Settings::Manager::setString ("character", "Saves",
slot->mPath.parent_path().filename().string()); slot->mPath.parent_path().filename().string());
} }
@ -246,6 +249,10 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
std::vector<std::string> buttons; std::vector<std::string> buttons;
buttons.push_back("#{sOk}"); buttons.push_back("#{sOk}");
MWBase::Environment::get().getWindowManager()->messageBox(error.str(), buttons); MWBase::Environment::get().getWindowManager()->messageBox(error.str(), buttons);
// If no file was written, clean up the slot
if (slot && !boost::filesystem::exists(slot->mPath))
mCharacterManager.getCurrentCharacter()->deleteSlot(slot);
} }
} }