Author Topic: [Issue]: Cyclic loop resulting in a silent crash  (Read 7143 times)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
[Issue]: Cyclic loop resulting in a silent crash
« on: November 15, 2006, 07:48:13 pm »
I tried to "implement" a cbMessageBox at a certain position and suddenly C::B didn't run anymore - instead it crashed silently. I realised the following issue with cbMessageBox:

- if cbMessageBox is called PlaceWindow will be called, but:
- if cbMessageBox is called with a NULL parent pointer, PlaceWindow receives the same
- PlaceWindow with thus issue a cbThrow which will raise a cbException which will use a cbMessageBox
- this again will call PlaceWindow with a NULL pointer... and so on...

You get the idea. cbMessageBox is not safe at all time (speaking about construction/destruction phase)... What to do about this?

My suggestion: Change
Code
    if(!w)
        cbThrow(_T("Passed NULL pointer to PlaceWindow."));
...in PlaceWindow to:
Code
    if(!w)
        cbThrow(_T("Passed NULL pointer to PlaceWindow."), true);
...which uses a wxSafeShowMessage instead of cbMessageBox... any objections?

Thomas? Yiannis? Others?

With regards, Morten.
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

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: [Issue]: Cyclic loop resulting in a silent crash
« Reply #1 on: November 15, 2006, 07:51:15 pm »
Sounds valid.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: [Issue]: Cyclic loop resulting in a silent crash
« Reply #2 on: November 15, 2006, 08:10:03 pm »
Agreed.
Be patient!
This bug will be fixed soon...

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: [Issue]: Cyclic loop resulting in a silent crash
« Reply #3 on: November 15, 2006, 08:27:03 pm »
Agreed.
Actually it's wrong. I mean: Using cbThrow(..., true) in PlaceWindow is ok.
But using wxMessageDialog in cbMessageBox with parent==NULL does not work anyway because wxMessageDialog *requires* a parent. I fixed it the following way:
In cbMessageBox, if parent==NULL use a wxMessageBox, otherwise use wxMessageDialog.

But: This limits the return values as they differ from wxMessageDialog. How to handle this (Will commit anytime soon for your inspection...)???

With regards, Morten.

Edit: I'll handle this by mapping the return values of wxMessageBox to the ones of wxMessageDialog. Committing now...
« Last Edit: November 15, 2006, 08:34:12 pm by MortenMacFly »
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

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2873
Re: [Issue]: Cyclic loop resulting in a silent crash
« Reply #4 on: November 15, 2006, 09:39:39 pm »
Edit: I'll handle this by mapping the return values of wxMessageBox to the ones of wxMessageDialog. Committing now...

Yeah. The samples do message box return code translation all over the place.
So does the source code for wxMessageBox.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
[SOLVED]: Cyclic loop resulting in a silent crash
« Reply #5 on: November 15, 2006, 09:53:37 pm »
Yeah. The samples do message box return code translation all over the place.
So does the source code for wxMessageBox.
...that's good (:?:) to know... ;-)
With regards, Morten.
« Last Edit: November 15, 2006, 09:55:21 pm by MortenMacFly »
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