summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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));