mail[Wesnoth-commits] r33848 - /trunk/src/gui/widgets/window.cpp


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

Header


Content

Posted by koraq on March 19, 2009 - 00:26:
Author: mordante
Date: Thu Mar 19 00:26:13 2009
New Revision: 33848

URL: http://svn.gna.org/viewcvs/wesnoth?rev=33848&view=rev
Log:
Handle layout problems more gracefully.

Instead of asserting show an error to the user, with this change the
asserts should really indicate an engine error.

Modified:
    trunk/src/gui/widgets/window.cpp

Modified: trunk/src/gui/widgets/window.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window.cpp?rev=33848&r1=33847&r2=33848&view=diff
==============================================================================
--- trunk/src/gui/widgets/window.cpp (original)
+++ trunk/src/gui/widgets/window.cpp Thu Mar 19 00:26:13 2009
@@ -24,6 +24,7 @@
 #include "font.hpp"
 #include "foreach.hpp"
 #include "game_display.hpp"
+#include "gettext.hpp"
 #ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
 #include "gui/widgets/debug.hpp"
 #endif
@@ -564,7 +565,6 @@
                // Fall back to the new layout engine.
                layout2(maximum_width, maximum_height);
                size = get_best_size();
-               assert(size.x <= maximum_width && size.y <= maximum_height);
        }
 
        /***** Does the height fit in the available height? ******/
@@ -592,7 +592,22 @@
                // Fall back to the new layout engine.
                layout2(maximum_width, maximum_height);
                size = get_best_size();
-               assert(size.x <= maximum_width && size.y <= maximum_height);
+       }
+
+       if(size.x > maximum_width || size.y > maximum_height) {
+
+               std::stringstream sstr;
+               sstr << __FILE__ << ":" << __LINE__ << " in function '" << 
__func__
+                               << "' found the following problem: Failed to 
size window;"
+                               << " wanted size " << size 
+                               << " available size "
+                               << maximum_width << ',' << maximum_height 
+                               << " screen size "
+                               << settings::screen_width << ',' << 
settings::screen_height
+                               << '.';
+
+               throw twml_exception(_("Failed to show a dialog, "
+                               "which doesn't fit on the screen."), 
sstr.str());
        }
 
        /***** Get the best location for the window *****/




Related Messages


Powered by MHonArc, Updated Thu Mar 19 01:40:31 2009