summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2008-05-17 03:29:16 +0000
committerbelugas <belugas@openttd.org>2008-05-17 03:29:16 +0000
commit17bd325574f452b76a3f87edf49cc2f9a39ddea7 (patch)
tree5903538b115052daa222f770031425851a70a95c /src/window.cpp
parent5199f5ff47028911d61eee22a6861bf03ef7b597 (diff)
downloadopenttd-17bd325574f452b76a3f87edf49cc2f9a39ddea7.tar.xz
(svn r13133) -Codechange: Add a base class (descending from Window) for all new windows that are going to require a ResetObjectToPlace to be performed on closing.
This will allow to free the said window only once, and not twice otherwise
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/window.cpp b/src/window.cpp
index 1b7430aee..c9bead7fd 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -2350,3 +2350,13 @@ void RelocateAllWindows(int neww, int newh)
w->top = top;
}
}
+
+/** Destructor of the base class PickerWindowBase
+ * Main utility is to stop the base Window destructor from triggering
+ * a free while the child will already be free, in this case by the ResetObjectToPlace().
+ */
+PickerWindowBase::~PickerWindowBase()
+{
+ this->window_class = WC_INVALID; // stop the ancestor from freeing the already (to be) child
+ ResetObjectToPlace();
+}