summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-05-07 21:45:27 +0000
committerrubidium <rubidium@openttd.org>2008-05-07 21:45:27 +0000
commit054552a30ba7a720e4977465048ced924a1f84e4 (patch)
treeb98d118eac65de9abd32926941d70a409f2c7a28
parent874d1ecfed55409c0fbaee9f9ed51dc8dda56339 (diff)
downloadopenttd-054552a30ba7a720e4977465048ced924a1f84e4.tar.xz
(svn r12999) -Fix [FS#1995]: when a Window got deleted on a double click event, we should not send a click event to the now non-existant Window as that causes segfaults.
-rw-r--r--src/window.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/window.cpp b/src/window.cpp
index 023b47fb4..e214d94e1 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -1931,9 +1931,14 @@ void MouseLoop(MouseClick click, int mousewheel)
}
} else {
switch (click) {
- case MC_DOUBLE_LEFT: DispatchLeftClickEvent(w, x - w->left, y - w->top, true);
- /* fallthough, and also give a single-click for backwards compatible */
- case MC_LEFT: DispatchLeftClickEvent(w, x - w->left, y - w->top, false); break;
+ case MC_DOUBLE_LEFT:
+ DispatchLeftClickEvent(w, x - w->left, y - w->top, true);
+ if (_mouseover_last_w == NULL) break; // The window got removed.
+ /* fallthough, and also give a single-click for backwards compatibility */
+ case MC_LEFT:
+ DispatchLeftClickEvent(w, x - w->left, y - w->top, false);
+ break;
+
default:
if (!scrollwheel_scrolling || w == NULL || w->window_class != WC_SMALLMAP) break;
/* We try to use the scrollwheel to scroll since we didn't touch any of the buttons.