From 8fcbca89cba178d6164a0bb1e6e317c88b694a32 Mon Sep 17 00:00:00 2001 From: Allanis <allanis@saracraft.net> Date: Wed, 27 Feb 2013 23:12:07 +0000 Subject: [PATCH] [Fix] I'd like to see VLack crash it now!! Allow for null pointer functions for buttons. --- src/menu.c | 6 +++--- src/toolkit.c | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/menu.c b/src/menu.c index 6ad2da2..5f4bdfd 100644 --- a/src/menu.c +++ b/src/menu.c @@ -104,13 +104,13 @@ void info_menu(void) { player->ship->name, "Ship", ship_view); window_addButton(wid, -20, (20 + BUTTON_HEIGHT)*3 + 20, BUTTON_WIDTH, BUTTON_HEIGHT, - "btnOutfits", "Outfits", ship_view); + "btnOutfits", "Outfits", NULL); window_addButton(wid, -20, (20 + BUTTON_HEIGHT)*2 + 20, BUTTON_WIDTH, BUTTON_HEIGHT, - "btnCargo", "Cargo", ship_view); + "btnCargo", "Cargo", NULL); window_addButton(wid, -20, 20 + BUTTON_HEIGHT + 20, BUTTON_WIDTH, BUTTON_HEIGHT, - "btnMissions", "Missions", ship_view); + "btnMissions", "Missions", NULL); window_addButton(wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnClose", "Close", info_menu_close); diff --git a/src/toolkit.c b/src/toolkit.c index 0049ef8..ad4750b 100644 --- a/src/toolkit.c +++ b/src/toolkit.c @@ -748,7 +748,13 @@ static void toolkit_mouseEvent(SDL_Event* event) { break; case SDL_MOUSEBUTTONUP: if(wgt->status == WIDGET_STATUS_MOUSEDOWN) { - if(wgt->type == WIDGET_BUTTON) (*wgt->dat.btn.fptr)(wgt->name); + if(wgt->type == WIDGET_BUTTON) { + if(wgt->dat.btn.fptr == NULL) + DEBUG("Toolkit: Button '%s' of Window '%s'" + "Does not have a function trigger", + wgt->name, w->name); + else (*wgt->dat.btn.fptr)(wgt->name); + } } wgt->status = WIDGET_STATUS_NORMAL; break;