[Fix] Outstanding memory write access issue.
This commit is contained in:
parent
b183286fdb
commit
353922fd3b
@ -278,7 +278,8 @@ void window_addCust(const unsigned int wid, const int x, const int y,
|
|||||||
static Widget* window_newWidget(Window* w) {
|
static Widget* window_newWidget(Window* w) {
|
||||||
Widget* wgt = NULL;
|
Widget* wgt = NULL;
|
||||||
|
|
||||||
w->widgets = realloc(w->widgets, sizeof(Widget)*(++w->nwidgets));
|
w->nwidgets++;
|
||||||
|
w->widgets = realloc(w->widgets, sizeof(Widget)*w->nwidgets);
|
||||||
if(w->widgets == NULL) WARN("Out of memory");
|
if(w->widgets == NULL) WARN("Out of memory");
|
||||||
|
|
||||||
wgt = &w->widgets[w->nwidgets - 1];
|
wgt = &w->widgets[w->nwidgets - 1];
|
||||||
@ -885,7 +886,7 @@ static void toolkit_mouseEvent(SDL_Event* event) {
|
|||||||
int i;
|
int i;
|
||||||
double x, y;
|
double x, y;
|
||||||
Window* w;
|
Window* w;
|
||||||
Widget* wgt;
|
Widget* wgt, *wgt_func;
|
||||||
|
|
||||||
// Set mouse button status.
|
// Set mouse button status.
|
||||||
if(event->type == SDL_MOUSEBUTTONDOWN) mouse_down = 1;
|
if(event->type == SDL_MOUSEBUTTONDOWN) mouse_down = 1;
|
||||||
@ -912,6 +913,7 @@ static void toolkit_mouseEvent(SDL_Event* event) {
|
|||||||
x -= w->x;
|
x -= w->x;
|
||||||
y -= w->y;
|
y -= w->y;
|
||||||
|
|
||||||
|
wgt_func = NULL;
|
||||||
for(i = 0; i < w->nwidgets; i++) {
|
for(i = 0; i < w->nwidgets; i++) {
|
||||||
wgt = &w->widgets[i];
|
wgt = &w->widgets[i];
|
||||||
// Widget in range?
|
// Widget in range?
|
||||||
@ -943,7 +945,8 @@ static void toolkit_mouseEvent(SDL_Event* event) {
|
|||||||
DEBUG("Toolkit: Button '%s' of Window '%s'"
|
DEBUG("Toolkit: Button '%s' of Window '%s'"
|
||||||
"Does not have a function trigger",
|
"Does not have a function trigger",
|
||||||
wgt->name, w->name);
|
wgt->name, w->name);
|
||||||
else (*wgt->dat.btn.fptr)(wgt->name);
|
else
|
||||||
|
wgt_func = wgt; // Run it at the end in case of close.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wgt->status = WIDGET_STATUS_NORMAL;
|
wgt->status = WIDGET_STATUS_NORMAL;
|
||||||
@ -956,6 +959,7 @@ static void toolkit_mouseEvent(SDL_Event* event) {
|
|||||||
else if(!mouse_down)
|
else if(!mouse_down)
|
||||||
wgt->status = WIDGET_STATUS_NORMAL;
|
wgt->status = WIDGET_STATUS_NORMAL;
|
||||||
}
|
}
|
||||||
|
if(wgt_func) (*wgt_func->dat.btn.fptr)(wgt_func->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle the key events.
|
// Handle the key events.
|
||||||
|
Loading…
Reference in New Issue
Block a user