From ad3f311251e5807c63169e1a4ad059f693bfcd0b Mon Sep 17 00:00:00 2001 From: "J.C. Jones" Date: Fri, 17 Dec 2004 14:57:28 +0000 Subject: [PATCH] Some assertion changes / removals from Dr. John Fay git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@524 7f0cb862-5218-0410-a997-914c9d46530a --- src/freeglut_cursor.c | 4 ++-- src/freeglut_display.c | 4 ++-- src/freeglut_internal.h | 7 ++++++- src/freeglut_menu.c | 2 +- src/freeglut_misc.c | 2 +- src/freeglut_window.c | 20 ++++++++++---------- 6 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/freeglut_cursor.c b/src/freeglut_cursor.c index 20ec0d8..0d30c32 100644 --- a/src/freeglut_cursor.c +++ b/src/freeglut_cursor.c @@ -84,7 +84,7 @@ static int fghGetCursorError( Cursor cursor ) void FGAPIENTRY glutSetCursor( int cursorID ) { freeglut_assert_ready; /* XXX WHY do we need the timer active for this? */ - freeglut_assert_window; + FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSetCursor" ); #if TARGET_HOST_UNIX_X11 /* @@ -237,7 +237,7 @@ void FGAPIENTRY glutSetCursor( int cursorID ) void FGAPIENTRY glutWarpPointer( int x, int y ) { freeglut_assert_ready; /* XXX WHY do we need the timer active for this? */ - freeglut_assert_window; + FREEGLUT_EXIT_IF_NO_WINDOW ( "glutWarpPointer" ); #if TARGET_HOST_UNIX_X11 diff --git a/src/freeglut_display.c b/src/freeglut_display.c index b29f1cc..74a0036 100644 --- a/src/freeglut_display.c +++ b/src/freeglut_display.c @@ -41,7 +41,7 @@ void FGAPIENTRY glutPostRedisplay( void ) { freeglut_assert_ready; - freeglut_assert_window; + FREEGLUT_EXIT_IF_NO_WINDOW ( "glutPostRedisplay" ); fgStructure.Window->State.Redisplay = GL_TRUE; } @@ -51,7 +51,7 @@ void FGAPIENTRY glutPostRedisplay( void ) void FGAPIENTRY glutSwapBuffers( void ) { freeglut_assert_ready; - freeglut_assert_window; + FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSwapBuffers" ); glFlush( ); if( ! fgStructure.Window->Window.DoubleBuffered ) diff --git a/src/freeglut_internal.h b/src/freeglut_internal.h index a032851..5b23df1 100644 --- a/src/freeglut_internal.h +++ b/src/freeglut_internal.h @@ -651,8 +651,13 @@ extern SFG_State fgState; * A call to those macros assures us that there is a current * window and menu set, respectively: */ -#define freeglut_assert_window assert( fgStructure.Window != NULL ); #define freeglut_assert_menu assert( fgStructure.Menu != NULL ); +#define FREEGLUT_EXIT_IF_NO_WINDOW( string ) \ + if ( ! fgStructure.Window ) \ + { \ + fgError ( " ERROR: Function <%s> called" \ + " with no current window defined.", (string) ) ; \ + } /* * The deinitialize function gets called on glutMainLoop() end. It should clean up diff --git a/src/freeglut_menu.c b/src/freeglut_menu.c index b22722d..9bdf9a0 100644 --- a/src/freeglut_menu.c +++ b/src/freeglut_menu.c @@ -394,7 +394,7 @@ void fgDisplayMenu( void ) SFG_Window* window = fgStructure.Window; SFG_Menu* menu = NULL; - freeglut_assert_window; + freeglut_return_if_fail ( fgStructure.Window != NULL ); /* Check if there is an active menu attached to this window... */ menu = window->ActiveMenu; diff --git a/src/freeglut_misc.c b/src/freeglut_misc.c index 932f6c7..e515b9b 100644 --- a/src/freeglut_misc.c +++ b/src/freeglut_misc.c @@ -96,7 +96,7 @@ void FGAPIENTRY glutReportErrors( void ) void FGAPIENTRY glutIgnoreKeyRepeat( int ignore ) { freeglut_assert_ready; - freeglut_assert_window; + FREEGLUT_EXIT_IF_NO_WINDOW ( "glutIgnoreKeyRepeat" ); fgStructure.Window->State.IgnoreKeyRepeat = ignore ? GL_TRUE : GL_FALSE; } diff --git a/src/freeglut_window.c b/src/freeglut_window.c index 5ba9cc5..da065e8 100644 --- a/src/freeglut_window.c +++ b/src/freeglut_window.c @@ -743,7 +743,7 @@ int FGAPIENTRY glutGetWindow( void ) void FGAPIENTRY glutShowWindow( void ) { freeglut_assert_ready; - freeglut_assert_window; + FREEGLUT_EXIT_IF_NO_WINDOW ( "glutShowWindow" ); #if TARGET_HOST_UNIX_X11 @@ -765,7 +765,7 @@ void FGAPIENTRY glutShowWindow( void ) void FGAPIENTRY glutHideWindow( void ) { freeglut_assert_ready; - freeglut_assert_window; + FREEGLUT_EXIT_IF_NO_WINDOW ( "glutHideWindow" ); #if TARGET_HOST_UNIX_X11 @@ -793,7 +793,7 @@ void FGAPIENTRY glutHideWindow( void ) void FGAPIENTRY glutIconifyWindow( void ) { freeglut_assert_ready; - freeglut_assert_window; + FREEGLUT_EXIT_IF_NO_WINDOW ( "glutIconifyWindow" ); fgStructure.Window->State.Visible = GL_FALSE; #if TARGET_HOST_UNIX_X11 @@ -817,7 +817,7 @@ void FGAPIENTRY glutIconifyWindow( void ) void FGAPIENTRY glutSetWindowTitle( const char* title ) { freeglut_assert_ready; - freeglut_assert_window; + FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSetWindowTitle" ); if( ! fgStructure.Window->Parent ) { #if TARGET_HOST_UNIX_X11 @@ -859,7 +859,7 @@ void FGAPIENTRY glutSetWindowTitle( const char* title ) void FGAPIENTRY glutSetIconTitle( const char* title ) { freeglut_assert_ready; - freeglut_assert_window; + FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSetIconTitle" ); if( ! fgStructure.Window->Parent ) { @@ -902,7 +902,7 @@ void FGAPIENTRY glutSetIconTitle( const char* title ) void FGAPIENTRY glutReshapeWindow( int width, int height ) { freeglut_assert_ready; - freeglut_assert_window; + FREEGLUT_EXIT_IF_NO_WINDOW ( "glutReshapeWindow" ); fgStructure.Window->State.NeedToResize = GL_TRUE; fgStructure.Window->State.Width = width ; @@ -915,7 +915,7 @@ void FGAPIENTRY glutReshapeWindow( int width, int height ) void FGAPIENTRY glutPositionWindow( int x, int y ) { freeglut_assert_ready; - freeglut_assert_window; + FREEGLUT_EXIT_IF_NO_WINDOW ( "glutPositionWindow" ); #if TARGET_HOST_UNIX_X11 @@ -949,7 +949,7 @@ void FGAPIENTRY glutPositionWindow( int x, int y ) void FGAPIENTRY glutPushWindow( void ) { freeglut_assert_ready; - freeglut_assert_window; + FREEGLUT_EXIT_IF_NO_WINDOW ( "glutPushWindow" ); #if TARGET_HOST_UNIX_X11 @@ -973,7 +973,7 @@ void FGAPIENTRY glutPushWindow( void ) void FGAPIENTRY glutPopWindow( void ) { freeglut_assert_ready; - freeglut_assert_window; + FREEGLUT_EXIT_IF_NO_WINDOW ( "glutPopWindow" ); #if TARGET_HOST_UNIX_X11 @@ -997,7 +997,7 @@ void FGAPIENTRY glutPopWindow( void ) void FGAPIENTRY glutFullScreen( void ) { freeglut_assert_ready; - freeglut_assert_window; + FREEGLUT_EXIT_IF_NO_WINDOW ( "glutFullScreen" ); { #if TARGET_HOST_UNIX_X11 -- 1.7.10.4