mail[Wesnoth-commits] r33471 - in /trunk/src: gamestatus.cpp replay.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by kailoran on March 08, 2009 - 21:12:
Author: ilor
Date: Sun Mar  8 21:12:02 2009
New Revision: 33471

URL: http://svn.gna.org/viewcvs/wesnoth?rev=33471&view=rev
Log:
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.

Modified:
    trunk/src/gamestatus.cpp
    trunk/src/replay.cpp

Modified: trunk/src/gamestatus.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gamestatus.cpp?rev=33471&r1=33470&r2=33471&view=diff
==============================================================================
--- trunk/src/gamestatus.cpp (original)
+++ trunk/src/gamestatus.cpp Sun Mar  8 21:12:02 2009
@@ -927,9 +927,16 @@
        }
 
        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 {

Modified: trunk/src/replay.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/replay.cpp?rev=33471&r1=33470&r2=33471&view=diff
==============================================================================
--- trunk/src/replay.cpp (original)
+++ trunk/src/replay.cpp Sun Mar  8 21:12:02 2009
@@ -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 @@
                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)




Related Messages


Powered by MHonArc, Updated Sun Mar 08 22:00:32 2009