[Plib-cvs] plib/src/pui pu.cxx,1.52,1.53 pu.h,1.111,1.112 puObject.cxx,1.42,1.43
Brought to you by:
sjbaker
From: James J. <pu...@us...> - 2002-07-12 01:01:27
|
Update of /cvsroot/plib/plib/src/pui In directory usw-pr-cvs1:/tmp/cvs-serv21955 Modified Files: pu.cxx pu.h puObject.cxx Log Message: Fixed memory leak in puCleanUpJunk, added puGetPressedButton, and PU_NOBUTTON to fix a potential problem with passive motion checkhits. Index: pu.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/pui/pu.cxx,v retrieving revision 1.52 retrieving revision 1.53 diff -u -d -r1.52 -r1.53 --- pu.cxx 20 Jun 2002 20:14:01 -0000 1.52 +++ pu.cxx 12 Jul 2002 01:01:24 -0000 1.53 @@ -222,12 +222,14 @@ static void puCleanUpJunk ( void ) { + puObject * local_objects_to_delete = objects_to_delete ; + objects_to_delete = NULL ; /* Step through the linked list of objects to delete, removing them. */ - while ( objects_to_delete != NULL ) + while ( local_objects_to_delete != NULL ) { - puObject *next_ob = objects_to_delete -> getNextObject() ; - delete objects_to_delete ; - objects_to_delete = next_ob ; + puObject *next_ob = local_objects_to_delete -> getNextObject() ; + delete local_objects_to_delete ; + local_objects_to_delete = next_ob ; } } @@ -349,6 +351,12 @@ static int pu_mouse_offset_x = 0 ; static int pu_mouse_offset_y = 0 ; +int puGetPressedButton () +{ + return last_buttons ; +} + + int puMouse ( int button, int updown, int x, int y ) { puCursor ( x, y ) ; @@ -392,13 +400,10 @@ { puCursor ( x, y ) ; - if ( last_buttons == 0 ) - return FALSE ; - int button = (last_buttons & (1<<PU_LEFT_BUTTON )) ? PU_LEFT_BUTTON : (last_buttons & (1<<PU_MIDDLE_BUTTON)) ? PU_MIDDLE_BUTTON : - (last_buttons & (1<<PU_RIGHT_BUTTON )) ? PU_RIGHT_BUTTON : 0 ; + (last_buttons & (1<<PU_RIGHT_BUTTON )) ? PU_RIGHT_BUTTON : PU_NOBUTTON ; int h = puGetWindowHeight () ; Index: pu.h =================================================================== RCS file: /cvsroot/plib/plib/src/pui/pu.h,v retrieving revision 1.111 retrieving revision 1.112 diff -u -d -r1.111 -r1.112 --- pu.h 7 Jul 2002 19:00:48 -0000 1.111 +++ pu.h 12 Jul 2002 01:01:24 -0000 1.112 @@ -54,6 +54,7 @@ #ifdef PU_NOT_USING_GLUT +#define PU_NOBUTTON -1 #define PU_LEFT_BUTTON 0 #define PU_MIDDLE_BUTTON 1 #define PU_RIGHT_BUTTON 2 @@ -62,6 +63,7 @@ #else +#define PU_NOBUTTON -1 #define PU_LEFT_BUTTON GLUT_LEFT_BUTTON #define PU_MIDDLE_BUTTON GLUT_MIDDLE_BUTTON #define PU_RIGHT_BUTTON GLUT_RIGHT_BUTTON @@ -428,6 +430,8 @@ void puSetActiveWidget ( puObject *w, int x, int y ) ; puObject *puActiveWidget ( void ) ; +// Return the currently active mouse button +extern int puGetPressedButton () ; class puValue { Index: puObject.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/pui/puObject.cxx,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- puObject.cxx 15 Apr 2002 20:40:11 -0000 1.42 +++ puObject.cxx 12 Jul 2002 01:01:24 -0000 1.43 @@ -488,13 +488,13 @@ int puObject::checkHit ( int button, int updown, int x, int y ) { - if ( isHit( x, y ) ) + if ( ( ( puGetPressedButton () || updown == PU_UP ) ) && isHit( x, y ) ) { doHit ( button, updown, x, y ) ; return TRUE ; } - lowlight () ; return FALSE ; } + |