summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-08-06 19:43:58 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-08-06 19:43:58 +0000
commit1df0f995cbcafa24a9312c25aa7c24fe910ed54c (patch)
treeb2c38e7c4f8b6d05a9afeb66a2909b4d13402124
parentd5bb76a134de27fd704cf2a76ad46df3026a8d0d (diff)
downloadmana-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.
-rw-r--r--ChangeLog6
-rw-r--r--src/gui/window.cpp19
2 files changed, 17 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 16267ef6..21d6ddd4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-08-06 Bjørn Lindeijer <bjorn@lindeijer.nl>
+
+ * src/gui/window.cpp: 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.
+
2008-08-05 David Athay <ko2fan@gmail.com>
* src/gui/setup_video.cpp, src/net/charserverhandler.cpp: Fixed
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));