mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r7635) -Fix (r7618, r7621): Guard against recursive deletion. It is possible that when a
parent window is deleted it deletes its child (always) and in turn, through some code the child initiates the deletion of the parent which, if not guarded against, deletes the child and so on...
This commit is contained in:
parent
662e25dded
commit
a64f7dc354
@ -1226,7 +1226,10 @@ static void QueryWndProc(Window *w, WindowEvent *e)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_DESTROY: /* Call callback function (if any) on window close if not yet called */
|
case WE_DESTROY: /* Call callback function (if any) on window close if not yet called */
|
||||||
if (!q->calledback && q->proc != NULL) q->proc(w->parent, false);
|
if (!q->calledback && q->proc != NULL) {
|
||||||
|
q->calledback = true;
|
||||||
|
q->proc(w->parent, false);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8
window.c
8
window.c
@ -308,10 +308,13 @@ Window **FindWindowZPosition(const Window *w)
|
|||||||
{
|
{
|
||||||
Window **wz;
|
Window **wz;
|
||||||
|
|
||||||
for (wz = _z_windows;; wz++) {
|
for (wz = _z_windows; wz != _last_z_window; wz++) {
|
||||||
assert(wz < _last_z_window);
|
|
||||||
if (*wz == w) return wz;
|
if (*wz == w) return wz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEBUG(misc, 3, "Window (class %d, number %d) is not open, probably removed by recursive calls",
|
||||||
|
w->window_class, w->window_number);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeleteWindow(Window *w)
|
void DeleteWindow(Window *w)
|
||||||
@ -342,6 +345,7 @@ void DeleteWindow(Window *w)
|
|||||||
/* Find the window in the z-array, and effectively remove it
|
/* Find the window in the z-array, and effectively remove it
|
||||||
* by moving all windows after it one to the left */
|
* by moving all windows after it one to the left */
|
||||||
wz = FindWindowZPosition(w);
|
wz = FindWindowZPosition(w);
|
||||||
|
if (wz == NULL) return;
|
||||||
memmove(wz, wz + 1, (byte*)_last_z_window - (byte*)wz);
|
memmove(wz, wz + 1, (byte*)_last_z_window - (byte*)wz);
|
||||||
_last_z_window--;
|
_last_z_window--;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user