diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-08-06 19:43:58 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-08-06 19:43:58 +0000 |
commit | 1df0f995cbcafa24a9312c25aa7c24fe910ed54c (patch) | |
tree | b2c38e7c4f8b6d05a9afeb66a2909b4d13402124 /src/gui/window.cpp | |
parent | d5bb76a134de27fd704cf2a76ad46df3026a8d0d (diff) | |
download | mana-1df0f995cbcafa24a9312c25aa7c24fe910ed54c.tar.gz mana-1df0f995cbcafa24a9312c25aa7c24fe910ed54c.tar.bz2 mana-1df0f995cbcafa24a9312c25aa7c24fe910ed54c.tar.xz mana-1df0f995cbcafa24a9312c25aa7c24fe910ed54c.zip |
Make sure only to save the window state when a window name is set, and fail
when loadWindowState() is called without setting a window name.
Diffstat (limited to 'src/gui/window.cpp')
-rw-r--r-- | src/gui/window.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 1c5072f5..ee8aca64 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -23,6 +23,7 @@ #include <algorithm> #include <climits> +#include <cassert> #include <guichan/exception.hpp> #include <guichan/widgets/icon.hpp> @@ -135,14 +136,15 @@ Window::~Window() const std::string &name = mWindowName; // Saving X, Y and Width and Height for resizables in the config - config.setValue(name + "WinX", getX()); - config.setValue(name + "WinY", getY()); - config.setValue(name + "Visible", isVisible()); - - if (mGrip) - { - config.setValue(name + "WinWidth", getWidth()); - config.setValue(name + "WinHeight", getHeight()); + if (!name.empty()) { + config.setValue(name + "WinX", getX()); + config.setValue(name + "WinY", getY()); + config.setValue(name + "Visible", isVisible()); + + if (mGrip) { + config.setValue(name + "WinWidth", getWidth()); + config.setValue(name + "WinHeight", getHeight()); + } } instances--; @@ -474,6 +476,7 @@ void Window::loadWindowState() { const std::string &name = mWindowName; + assert(!name.empty()); setPosition((int) config.getValue(name + "WinX", mDefaultX), (int) config.getValue(name + "WinY", mDefaultY)); |