projects
/
freeglut
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added a safety-check on a memory allocation. (Timers were using
[freeglut]
/
src
/
freeglut_structure.c
diff --git
a/src/freeglut_structure.c
b/src/freeglut_structure.c
index
da29757
..
09ad74d
100644
(file)
--- a/
src/freeglut_structure.c
+++ b/
src/freeglut_structure.c
@@
-168,7
+168,7
@@
SFG_Menu* fgCreateMenu( FGCBmenu menuCallback )
fgState.BuildingAMenu = FALSE ;
glutHideWindow () ; /* Hide the window for now */
fgState.BuildingAMenu = FALSE ;
glutHideWindow () ; /* Hide the window for now */
- fgStructure.Window = current_window ;
+ fgSetWindow ( current_window ) ;
/*
* Initialize the object properties:
/*
* Initialize the object properties:
@@
-273,6
+273,7
@@
void fgCloseWindows ()
void fgDestroyWindow( SFG_Window* window, GLboolean needToClose )
{
SFG_Window* subWindow;
void fgDestroyWindow( SFG_Window* window, GLboolean needToClose )
{
SFG_Window* subWindow;
+ int menu_index ;
assert( window != NULL );
freeglut_assert_ready;
assert( window != NULL );
freeglut_assert_ready;
@@
-296,9
+297,9
@@
void fgDestroyWindow( SFG_Window* window, GLboolean needToClose )
if ( window->Callbacks.Destroy != NULL )
{
SFG_Window *activeWindow = fgStructure.Window ;
if ( window->Callbacks.Destroy != NULL )
{
SFG_Window *activeWindow = fgStructure.Window ;
- fgStructure.Window = window ;
+ fgSetWindow ( window ) ;
window->Callbacks.Destroy () ;
window->Callbacks.Destroy () ;
- fgStructure.Window = activeWindow ;
+ fgSetWindow ( activeWindow ) ;
}
/*
}
/*
@@
-309,6
+310,15
@@
void fgDestroyWindow( SFG_Window* window, GLboolean needToClose )
else
fgListRemove( &fgStructure.Windows, &window->Node );
else
fgListRemove( &fgStructure.Windows, &window->Node );
+ if ( window->ActiveMenu != NULL )
+ fgDeactivateMenu ( window ) ;
+
+ for ( menu_index = 0; menu_index < 3; menu_index ++ )
+ {
+ if ( window->Menu[menu_index] != NULL )
+ window->Menu[menu_index]->ParentWindow = NULL ;
+ }
+
/*
* OK, this window seems disconnected from the structure enough
* in order to be closed without any bigger risks...
/*
* OK, this window seems disconnected from the structure enough
* in order to be closed without any bigger risks...
@@
-321,6
+331,7
@@
void fgDestroyWindow( SFG_Window* window, GLboolean needToClose )
* have everything inside it freed and we do not have to care...
*/
free( window );
* have everything inside it freed and we do not have to care...
*/
free( window );
+ if ( fgStructure.Window == window ) fgStructure.Window = NULL ;
}
/*
}
/*
@@
-432,6
+443,9
@@
void fgDestroyMenu( SFG_Menu* menu )
/*
* Destroy the window associated with the menu
*/
/*
* Destroy the window associated with the menu
*/
+ if ( fgStructure.Window == menu->Window )
+ fgSetWindow ( menu->ParentWindow ) ;
+
fgDestroyWindow ( menu->Window, TRUE ) ;
/*
fgDestroyWindow ( menu->Window, TRUE ) ;
/*
@@
-486,11
+500,11
@@
void fgDestroyStructure( void )
/*
* Make sure all windows and menus have been deallocated
*/
/*
* Make sure all windows and menus have been deallocated
*/
- while( (window = (SFG_Window *)fgStructure.Windows.First) != NULL )
- fgDestroyWindow( window, TRUE );
-
while( (menu = (SFG_Menu *)fgStructure.Menus.First) != NULL )
fgDestroyMenu( menu );
while( (menu = (SFG_Menu *)fgStructure.Menus.First) != NULL )
fgDestroyMenu( menu );
+
+ while( (window = (SFG_Window *)fgStructure.Windows.First) != NULL )
+ fgDestroyWindow( window, TRUE );
}
/*
}
/*