From 65c56b73e3c89fdadac46e601cd01fdafeeb64c9 Mon Sep 17 00:00:00 2001 From: Gerard Krol Date: Sat, 15 Dec 2007 14:33:56 +0000 Subject: [PATCH] Fix an invalid pointer reference in the widget code by making sure that the pointer to the widget currently under the mouse is cleared when the widget is freed. git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3064 4a71c877-e1ca-e34f-864e-861f7616d084 --- lib/widget/widget.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/widget/widget.c b/lib/widget/widget.c index 25ea87a4d..f14ca3db2 100644 --- a/lib/widget/widget.c +++ b/lib/widget/widget.c @@ -126,6 +126,13 @@ void widgReleaseWidgetList(WIDGET *psWidgets) for(psCurr = psWidgets; psCurr; psCurr = psNext) { psNext = psCurr->psNext; + + // the mouse can't be over it anymore + if (psMouseOverWidget && psMouseOverWidget->id == psCurr->id) + { + psMouseOverWidget = NULL; + } + switch(psCurr->type) { case WIDG_FORM: @@ -667,6 +674,11 @@ void widgDelete(W_SCREEN *psScreen, UDWORD id) { screenClearFocus(psScreen); } + // the mouse can't be over it anymore + if (psMouseOverWidget && psMouseOverWidget->id == id) + { + psMouseOverWidget = NULL; + } /* Set up the initial context */ sContext.psScreen = psScreen;