Author Topic: CodeBlocks program using CB 10.05 and wxSmith (wxWidgets-2.8.12) won't close  (Read 4678 times)

Offline Boleczek

  • Single posting newcomer
  • *
  • Posts: 3
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?
« Last Edit: September 19, 2012, 02:28:24 am by Boleczek »

Offline Radek

  • Multiple posting newcomer
  • *
  • Posts: 104
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).

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Unrelated to Code::Blocks, therefore locking the topic.

Please respect the forum rules you agreed to. Thank you.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ