RE: [Plib-users] pui help
Brought to you by:
sjbaker
From: Brian S. <sch...@ho...> - 2004-04-07 22:43:30
|
Bruce: Your right!! i didn't even realize that, how then would I create this object as a global variable, in my header file I just have puOneShot *backButton; to make it global, then when it gets to createTeamButtons() it does create a new one (why the address was different between the backButton created and the backButton called to hide). However if I put this line in the header file puOneShot *backButton = new puOneShot (20.0, 20.0, 170.0, 50.0); I get a fatal error before anything starts up saying FATAL: puiGetWindow: callbacks are not initialized I'm guessing this is so because at the time of the .h file I have not initialized pui yet. So how would I create a global object?? -Brian >Brian: > I had to go back to my deleted mail to check this. In one of your >later mails you said that backButton is global but you are redefining it >in: > >void createTeamButtons() { > puOneShot *backButton = new puOneShot (20.0, 20.0, 170.0, 50.0); >... > > >You may want to double check that > >Bruce > >-----Original Message----- >From: pli...@li... >[mailto:pli...@li...] On Behalf Of Brian Smith >Sent: Tuesday, April 06, 2004 10:20 PM >To: pli...@li... >Subject: Re: [Plib-users] pui help > > > > > >Brian Smith wrote: > >>Running VC++6.0 with windows XP, plib 1.8.2, I was wondering if anyone > >>could help me out, I need to hide puObjects but whenever I use >.hide() > >>the program crashes and I get an unhandled exception: access >violation. > >>Any suggestions?? thanks in advance. > > > >Well, I've used hide() quite a bit with no problems - we're going to > >need a LOT more information if this is truly a PLIB bug. > > > >It crashes inside hide() ? > > > >If so, it *MUST* be that the puObject you are calling it on is an > >invalid pointer...all hide() does is access an internal member and call > > >puPostRefresh - and all THAT does is set a global. > > > >However, if calling hide() causes it to die sometime later then we > >could be looking at something complicated. > > > >Could you get us a stack back-trace from the crash? Or maybe > >show us some source code? > > > >I'll try and explain what the program is doind and show ya the relevant >source. I have two display functions, the first one has no pui objects >at >all but when i switch to the second display function there are some >buttons >on it, one of the buttons I have is a back button which returns to the >first >display function. > >so when the second display function is eventually called I call the >function >createTeamButtons() which is this: > >void createTeamButtons() { > puOneShot *backButton = new puOneShot (20.0, 20.0, 170.0, 50.0); > backButton->setLegend("Back"); > backButton->setCallback(backButtonCallback); >} > >the callback function for this button (backButtonCallback) is this: > >void backButtonCallback(puObject *) { > glutKeyboardFunc(NULL); > glutSpecialFunc(NULL); > glutIdleFunc(Main_Display); > glutDisplayFunc(Main_Display); > glutPassiveMotionFunc(Main_MouseMove); > glutMouseFunc(Main_MouseChoose); > hideTeamButtons(); >} > >and hide TeamButtons() is this: > >void hideTeamButtons() { > backButton->hide(); >} > >so in the program when I click the back button the program crashes and >an >error dialog pops up saying: > >Unhandled exception in program.exe: 0xC0000005: Access Violation. > >I say it crashes on hide because: 1)when I debug it is calling the hide > >function in pu.h while crash > 2)if hide() isn't in >hideTeamButtons() (I was gonna try just > deleting everything >everytime the program returns to the first > display function but >figured hide would be much easier) > >there are more buttons for the second display function but this is the >most >relevent one, if I try hide one or hide them all doesn't matter so only >put >the one in. Thats all i got for ya, if theres anything else ya want let >me >know. > >-Brian _________________________________________________________________ Persistent heartburn? Check out Digestive Health & Wellness for information and advice. http://gerd.msn.com/default.asp |