summaryrefslogtreecommitdiff
path: root/src/viewport.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-05-15 20:52:28 +0000
committerrubidium <rubidium@openttd.org>2008-05-15 20:52:28 +0000
commit2704b12f2b018ec02db01c5fb391f31b1d632124 (patch)
tree08ad356704dc06b347c0d8e9ddcde18edc80ed1c /src/viewport.cpp
parent447ed7a2a56774c3a71d75ce413262d890ec1397 (diff)
downloadopenttd-2704b12f2b018ec02db01c5fb391f31b1d632124.tar.xz
(svn r13110) -Fix [FS#2018]: some toolbar buttons not being unpressed properly.
Diffstat (limited to 'src/viewport.cpp')
-rw-r--r--src/viewport.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 10369e1ec..f090a7565 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -2708,11 +2708,18 @@ void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, ViewportHighlightMode mode
void SetObjectToPlace(CursorID icon, SpriteID pal, ViewportHighlightMode mode, WindowClass window_class, WindowNumber window_num)
{
- Window *w = NULL;
-
/* undo clicking on button and drag & drop */
if (_thd.place_mode != VHM_NONE || _special_mouse_mode == WSM_DRAGDROP) {
- w = FindWindowById(_thd.window_class, _thd.window_number);
+ Window *w = FindWindowById(_thd.window_class, _thd.window_number);
+ if (w != NULL) {
+ /* Call the abort function, but set the window class to something
+ * that will never be used to avoid infinite loops. Setting it to
+ * the 'next' window class must not be done because recursion into
+ * this function might in some cases reset the newly set object to
+ * place or not properly reset the original selection. */
+ _thd.window_class = WC_INVALID;
+ w->OnPlaceObjectAbort();
+ }
}
SetTileSelectSize(1, 1);
@@ -2739,10 +2746,6 @@ void SetObjectToPlace(CursorID icon, SpriteID pal, ViewportHighlightMode mode, W
SetMouseCursor(icon, pal);
}
- /* Call the abort function only *after* the window class/number
- * are reset so one doesn't get into infinite loops when someone
- * resets the object to place during the abort callback. */
- if (w != NULL) w->OnPlaceObjectAbort();
}
void ResetObjectToPlace()