summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2015-03-13 20:54:35 +0000
committerrubidium <rubidium@openttd.org>2015-03-13 20:54:35 +0000
commit06d7d63216d7e5e2265353c7b45dbf6d7bafa3a7 (patch)
tree1503f120b18c7f3305ce0e9926c37a86619b0ca4
parent20e20d6d2b85f92c87c2bdda2f82a0ef9402be93 (diff)
downloadopenttd-06d7d63216d7e5e2265353c7b45dbf6d7bafa3a7.tar.xz
(svn r27185) -Fix: prevent the compiler from optimizing an assignment away which caused GCC 5 to actually crash
-rw-r--r--src/window.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/window.cpp b/src/window.cpp
index ff24dbd3b..18e8f3588 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -1079,7 +1079,16 @@ Window::~Window()
free(this->nested_array); // Contents is released through deletion of #nested_root.
delete this->nested_root;
- this->window_class = WC_INVALID;
+ /*
+ * Make fairly sure that this is written, and not "optimized" away.
+ * The delete operator is overwritten to not delete it; the deletion
+ * happens at a later moment in time after the window has been
+ * removed from the list of windows to prevent issues with items
+ * being removed during the iteration as not one but more windows
+ * may be removed by a single call to ~Window by means of the
+ * DeleteChildWindows function.
+ */
+ const_cast<volatile WindowClass &>(this->window_class) = WC_INVALID;
}
/**