From: J.C. Jones Date: Mon, 8 Sep 2003 20:36:23 +0000 (+0000) Subject: Menus should deallocate better now - John Fay X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=commitdiff_plain;h=2433cf0a62aea70942f3645c6d4d90bd43d99691;p=freeglut Menus should deallocate better now - John Fay git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@178 7f0cb862-5218-0410-a997-914c9d46530a --- diff --git a/src/freeglut_main.c b/src/freeglut_main.c index 6219980..bdfe139 100644 --- a/src/freeglut_main.c +++ b/src/freeglut_main.c @@ -793,12 +793,13 @@ void FGAPIENTRY glutMainLoopEvent( void ) /* Save the current window and menu and set the current window to the window whose menu this is */ SFG_Window *save_window = fgStructure.Window ; SFG_Menu *save_menu = fgStructure.Menu ; + SFG_Window *parent_window = window->ActiveMenu->ParentWindow ; fgSetWindow ( window ) ; fgStructure.Menu = window->ActiveMenu ; /* Execute the menu callback */ fgExecuteMenuCallback ( window->ActiveMenu ) ; - fgDeactivateMenu ( window->ActiveMenu->ParentWindow ) ; + fgDeactivateMenu ( parent_window ) ; /* Restore the current window and menu */ fgSetWindow ( save_window ) ; diff --git a/src/freeglut_structure.c b/src/freeglut_structure.c index d8e09ad..454aebf 100644 --- a/src/freeglut_structure.c +++ b/src/freeglut_structure.c @@ -321,6 +321,7 @@ void fgDestroyWindow( SFG_Window* window, GLboolean needToClose ) * have everything inside it freed and we do not have to care... */ free( window ); + if ( fgStructure.Window == window ) fgStructure.Window = NULL ; } /* @@ -432,6 +433,9 @@ void fgDestroyMenu( SFG_Menu* menu ) /* * Destroy the window associated with the menu */ + if ( fgStructure.Window == menu->Window ) + fgSetWindow ( menu->ParentWindow ) ; + fgDestroyWindow ( menu->Window, TRUE ) ; /*