summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-04-13 19:06:30 +0000
committerrubidium <rubidium@openttd.org>2008-04-13 19:06:30 +0000
commit1fe1b5da80e4dca34141111b84cf989dcb226a79 (patch)
tree776ff1f17e8172a0b1ac77a9fcf28ea49340fa31 /src
parent99b51aa2351d61138faf715764c036c21829dde6 (diff)
downloadopenttd-1fe1b5da80e4dca34141111b84cf989dcb226a79.tar.xz
(svn r12694) -Fix: do not call the mouse over callback on already deleted windows.
Diffstat (limited to 'src')
-rw-r--r--src/window.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/window.cpp b/src/window.cpp
index cd2dcfc6e..082f1c302 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -22,7 +22,8 @@
#include "table/sprites.h"
-static Point _drag_delta; //< delta between mouse cursor and upper left corner of dragged window
+static Point _drag_delta; ///< delta between mouse cursor and upper left corner of dragged window
+static Window *_mouseover_last_w = NULL; ///< Window of the last MOUSEOVER event
static Window _windows[MAX_NUMBER_OF_WINDOWS];
@@ -423,6 +424,9 @@ void DeleteWindow(Window *w)
w->widget_count = 0;
w->parent = NULL;
+ /* Prevent Mouseover() from resetting mouse-over coordinates on a non-existing window */
+ if (_mouseover_last_w == w) _mouseover_last_w = NULL;
+
/* Find the window in the z-array, and effectively remove it
* by moving all windows after it one to the left */
Window **wz = FindWindowZPosition(w);
@@ -1197,20 +1201,21 @@ static bool HandlePopupMenu()
static bool HandleMouseOver()
{
- Window *w;
WindowEvent e;
- static Window *last_w = NULL;
- w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y);
+ Window *w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y);
/* We changed window, put a MOUSEOVER event to the last window */
- if (last_w != NULL && last_w != w) {
+ if (_mouseover_last_w != NULL && _mouseover_last_w != w) {
+ /* Reset mouse-over coordinates of previous window */
e.event = WE_MOUSEOVER;
e.we.mouseover.pt.x = -1;
e.we.mouseover.pt.y = -1;
- if (last_w->wndproc) last_w->wndproc(last_w, &e);
+ if (_mouseover_last_w->wndproc != NULL) _mouseover_last_w->wndproc(_mouseover_last_w, &e);
}
- last_w = w;
+
+ /* _mouseover_last_w will get reset when the window is deleted, see DeleteWindow() */
+ _mouseover_last_w = w;
if (w != NULL) {
/* send an event in client coordinates. */