work around bug #12450...

(boost issue previously marked as 'upstream problem') by not using
boost iostreams to write directly to disk, instead, write to a
stringstream and thenoutput that to a file. This makes Wesnoth no
longer hang when a save is issued with insufficient disk space.
This commit is contained in:
Tomasz Śniatowski 2009-03-08 21:12:02 +01:00
parent 57e9857bbc
commit ce94b5c7fc
2 changed files with 21 additions and 7 deletions

View File

@ -927,9 +927,16 @@ void save_game(const game_state& gamestate)
}
scoped_ostream os(open_save_game(filename));
config_writer out(*os, preferences::compress_saves());
write_game(out, gamestate);
finish_save_game(out, gamestate, gamestate.label);
std::stringstream ss;
{
config_writer out(ss, preferences::compress_saves());
write_game(out, gamestate);
finish_save_game(out, gamestate, gamestate.label);
}
(*os) << ss.str();
if (!os->good()) {
throw game::save_game_failed(_("Could not write to file"));
}
}
namespace {

View File

@ -26,6 +26,7 @@
#include "game_end_exceptions.hpp"
#include "game_preferences.hpp"
#include "game_events.hpp"
#include "gettext.hpp"
#include "log.hpp"
#include "map.hpp"
#include "map_label.hpp"
@ -212,13 +213,19 @@ void replay::save_game(const std::string& label, const config& snapshot,
filename += ".gz";
}
std::stringstream ss;
{
config_writer out(ss, preferences::compress_saves());
::write_game(out, saveInfo_);
finish_save_game(out, saveInfo_, saveInfo_.label);
}
scoped_ostream os(open_save_game(filename));
config_writer out(*os, preferences::compress_saves());
::write_game(out, saveInfo_);
finish_save_game(out, saveInfo_, saveInfo_.label);
(*os) << ss.str();
saveInfo_.replay_data = config();
saveInfo_.snapshot = config();
if (!os->good()) {
throw game::save_game_failed(_("Could not write to file"));
}
}
void replay::add_unit_checksum(const map_location& loc,config* const cfg)