summaryrefslogtreecommitdiff
path: root/window.c
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2006-12-04 13:36:27 +0000
committerrubidium <rubidium@openttd.org>2006-12-04 13:36:27 +0000
commitc02e39945e2533c7f51f650bcaa00fa11af6a784 (patch)
tree87b758a53a963b20bb7bf0e88784a52d0e736c58 /window.c
parent7086936bab7dc7d7ab7715e3b57fb19ebc019367 (diff)
downloadopenttd-c02e39945e2533c7f51f650bcaa00fa11af6a784.tar.xz
(svn r7352) -Codechange: add widget_count parameter to the window.
-Codechange: check whether widget indices are valid for all the (Set|Is)WindowWidget(Disabled|Lowered|Hidden) and related functions.
Diffstat (limited to 'window.c')
-rw-r--r--window.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/window.c b/window.c
index 58de0affa..2b9d10910 100644
--- a/window.c
+++ b/window.c
@@ -316,6 +316,7 @@ void DeleteWindow(Window *w)
SetWindowDirty(w);
free(w->widget);
w->widget = NULL;
+ w->widget_count = 0;
/* Find the window in the z-array, and effectively remove it
* by moving all windows after it one to the left */
@@ -519,8 +520,10 @@ void AssignWidgetToWindow(Window *w, const Widget *widget)
w->widget = realloc(w->widget, sizeof(*w->widget) * index);
memcpy(w->widget, widget, sizeof(*w->widget) * index);
+ w->widget_count = index - 1;
} else {
w->widget = NULL;
+ w->widget_count = 0;
}
}
@@ -877,6 +880,7 @@ void UnInitWindowSystem(void)
FOR_ALL_WINDOWS(wz) {
free((*wz)->widget);
(*wz)->widget = NULL;
+ (*wz)->widget_count = 0;
}
}