If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Is it possible to show a dialog from wxApp::OnExit. I am using wxMac 2.6.3 on Mac OS X and I get a crash on the ShowModal line of the snippet below. I don't see anything that says I shouldn't do be able to show dialogs and I am able to use the wxMessageDialog's fine from the OnInit() function, so I thought I would be able to do so in OnExit to.
#0 0x7c000005 in ?? ()
#1 0x038c53ad in wxTimerBase::Notify (this=0x91cf770) at ../src/common/timercmn.cpp:61
#2 0x03824513 in wxProcessTimer (theTimer=0x91cf800, data=0x91cf770) at ../src/mac/carbon/timer.cpp:53
#3 0x92f3a8c2 in TimerVector ()
#4 0x90823bc9 in CFRunLoopRunSpecific ()
#5 0x90822eb5 in CFRunLoopRunInMode ()
#6 0x92f02b90 in RunCurrentEventLoopInMode ()
#7 0x92f021ce in ReceiveNextEventCommon ()
#8 0x93017b91 in ReceiveNextEvent ()
#9 0x037d62b4 in wxApp::MacDoOneEvent (this=0x9110370) at ../src/mac/carbon/app.cpp:1232
#10 0x037f5316 in wxDialog::DoShowModal (this=0x884b400) at ../src/mac/carbon/dialog.cpp:185
#11 0x037f53ab in wxDialog::Show (this=0x884b400, show=true) at ../src/mac/carbon/dialog.cpp:151
#12 0x037f568b in wxDialog::ShowModal (this=0x884b400) at ../src/mac/carbon/dialog.cpp:206
#13 0x000045ac in ssl::myApp::OnExit (this=0x9110370) at /path/to/my/project/dir/../src/myapp.cpp:145
int myApp::OnExit()
{
wxTextEntryDialog* dlg = new
wxTextEntryDialog(NULL,
wxT("Do you want save the config to the following"
"file?\nCurrent config will be overwritten"),
wxT(m_config->getFileName().c_str()));
if(dlg->ShowModal() == wxID_OK)
m_config->saveToDisk();
delete m_config;
return wxApp::OnExit();
}
Thank you both, in my frame I had a timer that I didn't stop upon destruction of the object. It is odd that it did not cause any problems up to this point. After I made sure to properly stop the timer the dialog displayed fine.
I don't currently store the pointer to my main frame, but it would probably be a good idea to do so. It is still safe to use the main frame from OnExit, is it not?