From: Diederick Niehorster Date: Wed, 27 Feb 2013 10:29:24 +0000 (+0000) Subject: fgDeactivateMenu could sometimes be called twice on the same menu, avoid X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=commitdiff_plain;h=378de1f7693a73536400c7de8889d8b6bec1641f;p=freeglut fgDeactivateMenu could sometimes be called twice on the same menu, avoid crash in that situation git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1524 7f0cb862-5218-0410-a997-914c9d46530a --- diff --git a/src/fg_menu.c b/src/fg_menu.c index 4f8e1a6..e60a5f8 100644 --- a/src/fg_menu.c +++ b/src/fg_menu.c @@ -679,6 +679,7 @@ GLboolean fgCheckActiveMenu ( SFG_Window *window, int button, GLboolean pressed, /* * Deactivates a menu pointed by the function argument. */ +static SFG_Menu* menuDeactivating = NULL; void fgDeactivateMenu( SFG_Window *window ) { SFG_Window *parent_window = NULL; @@ -690,6 +691,10 @@ void fgDeactivateMenu( SFG_Window *window ) /* Check if there is an active menu attached to this window... */ menu = window->ActiveMenu; freeglut_return_if_fail( menu ); + /* Check if we are already deactivating this menu, abort in that case (glutHideWindow below can cause this function to be called again on the same menu..) */ + if (menu==menuDeactivating) + return; + menuDeactivating = menu; parent_window = menu->ParentWindow; @@ -717,6 +722,8 @@ void fgDeactivateMenu( SFG_Window *window ) if( menuEntry->SubMenu ) fghDeactivateSubMenu( menuEntry ); } + /* Done deactivating menu */ + menuDeactivating = NULL; fgSetWindow ( parent_window ) ;