Code::Blocks Forums
User forums => Help => Topic started by: Boleczek on September 18, 2012, 10:37:07 pm
-
My CodeBlocks project built with CB 10.05 and wxSmith (installed wxWidgets-2.8.12) on a Windows 7 machine will not close correctly. The project consists of a simple window which includes only a wxPanel with a wxStaticText which can build and run but when I try to close it I get the following error message:
"CGC.exe has stopped working. A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available."
I tried debugging in CB and found that the error occurrs at the Close() routine:
void CGCFrame::OnClose(wxCloseEvent& event)
{
Close();
}
If I use Destroy(); in place of Close(); the program closes without any errors.
Using the same setup on an XP machine and do not have this problem.
Any suggestions why this is happening and how to fix it?
-
I do not use winblows but some hints:
The OnClose() handler is connected to wxEVT_WINDOW_CLOSE by default. This event is triggered by Close() itself so that your code snippet might contain an infinite loop. wxWidgets states that it is protected from that loop but it also tells you that you should not rely too much on it :-\ The normal processing of wxEVT_WINDOW_CLOSE is calling Destroy() instead of Close().
The example programs in wxWidgets use OnQuit() rather than OnClose(). Either use OnQuit() and call Close() from OnQuit() or Connect() to wxEVT_WINDOW_CLOSE and call Destroy() from the handler. The later method is necessary if your main window is a modeless dialog (closing a modeless dialog = hiding it by default, not quitting it).
-
Unrelated to Code::Blocks, therefore locking the topic.
Please respect the forum rules you agreed to. Thank you.