[Plib-users] Crash while deleting puDialogBox... access violation
Brought to you by:
sjbaker
From: SkyFlash <sky...@ch...> - 2003-04-01 04:35:51
|
I have a strange crash I dont really understand... If there is anyone that has experienced something similar and knows a solution please speak up. :) Basicly, I create a dialogbox, and close it when the callback for the button inside it is called. Once it closes I get a crash, access violation. Traceback: puOneShot::doHit(int 0, int 1, int 243, int 34) line 33 + 12 bytes puObject::checkHit(int 0, int 1, int 243, int 34) line 508 + 29 bytes puGroup::checkHit(int 0, int 1, int 243, int 34) line 212 + 29 bytes puMouse(int 0, int 1, int 394, int 316) line 378 + 42 bytes mouse(int 0, int 1, int 394, int 316) line 1004 + 21 bytes FREEGLUT! 0089661d() I made sure that the dialog box destructor was called before that, so somehow PUI seems to maintain the pointer somewhere internally and call it even after it was destroyed. (I think?) It may have something to do with the LiveInterface code(??), but I didnt manage to trace it down. Its prolly something stupid and I just dont see it.. sigh. Do I need to tell PUI I am deleting that dialogbox AND the buttons inside it?? Clean something up? Pop some interface from the stack?? Thx for any answer you might have... Ralf Pietersz Here is the code: ---------- snip ------------ void ClientApp::CreateNoticeBox (string text) { if (m_dialogbox != 0) return; if (m_dialogboxtext) delete m_dialogboxtext; m_dialogboxtext = new char [255]; strcpy (m_dialogboxtext, text.substr (0,254).c_str ()); m_dialogbox = new puDialogBox (puGetWindowWidth()/2-250, puGetWindowHeight()/2-50); { new puFrame (0, 0, 500, 100); puText* text = new puText (10, 55); text->setLabel (m_dialogboxtext); puOneShot* ok = new puOneShot (220, 15, 280, 45); ok->setLegend ("OK"); ok->setCallback (closedialogbox); } m_dialogbox->close (); m_dialogbox->reveal (); } void ClientApp::DestroyNoticeBox () { if (m_dialogbox) delete m_dialogbox; if (m_dialogboxtext) delete m_dialogboxtext; m_dialogbox = 0; m_dialogboxtext = 0; } static void closedialogbox (puObject *ob) { app->DestroyNoticeBox (); } static void mouse ( int button, int updown, int x, int y ) { puMouse ( button, updown, x, y ); glutPostRedisplay () ; app->HandleMouseClicks (button,updown,x,y); } |