Menus should deallocate better now - John Fay
authorJ.C. Jones <jc@insufficient.coffee>
Mon, 8 Sep 2003 20:36:23 +0000 (20:36 +0000)
committerJ.C. Jones <jc@insufficient.coffee>
Mon, 8 Sep 2003 20:36:23 +0000 (20:36 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@178 7f0cb862-5218-0410-a997-914c9d46530a

src/freeglut_main.c
src/freeglut_structure.c

index 6219980..bdfe139 100644 (file)
@@ -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 ) ;
index d8e09ad..454aebf 100644 (file)
@@ -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 ) ;
 
   /*