X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=freeglut-1.3%2Ffreeglut_structure.c;h=2c262590ef9e69336c54da9196789ef20011253b;hb=9d66916bab11e22ff2b670638be3a50e604897a1;hp=d3696ba36f4d917f287c451ed032168aff3d3be0;hpb=a82e219413778d1fd55d270af98e9ad6a97e25a0;p=freeglut diff --git a/freeglut-1.3/freeglut_structure.c b/freeglut-1.3/freeglut_structure.c index d3696ba..2c26259 100644 --- a/freeglut-1.3/freeglut_structure.c +++ b/freeglut-1.3/freeglut_structure.c @@ -32,7 +32,7 @@ #define G_LOG_DOMAIN "freeglut-structure" #include "../include/GL/freeglut.h" -#include "../include/GL/freeglut_internal.h" +#include "freeglut_internal.h" /* -- GLOBAL EXPORTS ------------------------------------------------------- */ @@ -179,6 +179,17 @@ void fgAddToWindowDestroyList ( SFG_Window* window, GLboolean needToClose ) WindowsToDestroy = new_list_entry ; /* + * Check if the window is the current one... + */ + if ( fgStructure.Window == window ) + fgStructure.Window = NULL; + + /* + * If the destroyed window has the highest window ID number, decrement the window ID number + */ + if ( window->ID == fgStructure.WindowID ) fgStructure.WindowID-- ; + + /* * Check the execution state. If this has been called from "glutDestroyWindow", * a statement in that function will reset the "ExecState" after this function returns. */ @@ -197,10 +208,8 @@ void fgAddToWindowDestroyList ( SFG_Window* window, GLboolean needToClose ) */ void fgCloseWindows () { - fgExecutionState ExecState = fgState.ExecState ; - SFG_WindowList *window_ptr = WindowsToDestroy ; - WindowsToDestroy = (SFG_WindowList*)NULL ; // In case the destroy callbacks cause more windows to be closed + WindowsToDestroy = (SFG_WindowList*)NULL ; /* In case the destroy callbacks cause more windows to be closed */ while ( window_ptr ) { @@ -209,14 +218,12 @@ void fgCloseWindows () free ( window_ptr ) ; window_ptr = next ; - if ( !window_ptr ) window_ptr = WindowsToDestroy ; + if ( !window_ptr ) + { + window_ptr = WindowsToDestroy ; + WindowsToDestroy = (SFG_WindowList*)NULL ; + } } - - /* - * Since the "fgDestroyWindow" function could easily have set the "ExecState" to stop, - * let's set it back to what it was. - */ - fgState.ExecState = ExecState ; } /* @@ -247,7 +254,12 @@ void fgDestroyWindow( SFG_Window* window, GLboolean needToClose ) * If the programmer defined a destroy callback, call it */ if ( window->Callbacks.Destroy != NULL ) + { + SFG_Window *activeWindow = fgStructure.Window ; + fgStructure.Window = window ; window->Callbacks.Destroy () ; + fgStructure.Window = activeWindow ; + } /* * Now we should remove the reference to this window from its parent @@ -265,12 +277,6 @@ void fgDestroyWindow( SFG_Window* window, GLboolean needToClose ) fgCloseWindow( window ); /* - * Check if the window is the current one... - */ - if( fgStructure.Window == window ) - fgStructure.Window = NULL; - - /* * Finally, we can delete the window's object. It hopefully does * have everything inside it freed and we do not have to care... */