Assert when trying to Enable buttons

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
Maeglix
Experienced Solver
Experienced Solver
Posts: 74
Joined: Thu Nov 17, 2016 8:07 am

Assert when trying to Enable buttons

Post by Maeglix »

Hi !

For some reasons, i have some buttons that i need to enable / disable at the start / end of an operation.
So at the start of the operation i disable the buttons. Everything works fine.
But at the end when i enable the buttons i have this assert: assert: ""source"" failed in DoClientToScreen(): ClientToScreen failed on unrealized window.

I guess the main point is this "unrealized window" but i don't see the problem. Moreover, if i click on "continue" on the assert panel everything has been done correctly.

Here the way i enable / disable the buttons:

Code: Select all

wxButtons* button = (wxButtons*) FindWindowById(ID_Buttons)
if (...)
{
    button->Enable(true);
}
else
{
    button->Enable(false);
}

Thanks for your help.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Assert when trying to Enable buttons

Post by doublemax »

(I assume wxButtons* should be wxButton*)
If the pointer is correct, i don't see how it could fail.

Try this:

Code: Select all

wxWindow *win = wxDynamicCast( FindWindowById(ID_Buttons), wxWindow );
if( win != NULL )
{
  // ...
}
Use the source, Luke!
Maeglix
Experienced Solver
Experienced Solver
Posts: 74
Joined: Thu Nov 17, 2016 8:07 am

Re: Assert when trying to Enable buttons

Post by Maeglix »

Yes, it is wxButton*, my bad.
I tried your code, it doesn't change anything.

I just saw that, on the 4 buttons i enable /disable, only one causes this issue. This button is inside a "popup" (my popup class is derived from wxMiniFrame) that can be hide when i enable / disable the buttons. That could explain the "unrealize window" but in this case, why does it work for the disable at the start of the operation and not for the enable at the end of the operation ?

Edit: I forgot to precise that my code is working perfectly on CentOs7 but i have the assert issue on CentOs5.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Assert when trying to Enable buttons

Post by doublemax »

Edit: I forgot to precise that my code is working perfectly on CentOs7 but i have the assert issue on CentOs5.
That probably means there is no real solution, you just have to shuffle the code around until it works ;)

Are you maybe trying to enable the button when the frame is already hidden?
Use the source, Luke!
Maeglix
Experienced Solver
Experienced Solver
Posts: 74
Joined: Thu Nov 17, 2016 8:07 am

Re: Assert when trying to Enable buttons

Post by Maeglix »

That probably means there is no real solution, you just have to shuffle the code around until it works
I guess so. I will try to find a workaround.
Are you maybe trying to enable the button when the frame is already hidden?
Yeah that's why i'm doing. This is why: the operation is made in a thread so the user can still interact while the operation is running. But in the case of this popup (which is hidden by default), i don't want that the user use a button inside it. So i disable the button and enable it when the operation is over.

But why does it work for the disable and not for the enable ?
Maeglix
Experienced Solver
Experienced Solver
Posts: 74
Joined: Thu Nov 17, 2016 8:07 am

Re: Assert when trying to Enable buttons

Post by Maeglix »

Currently i fix it be showing the popup, enabling the button, hidden popup. It seems enough fast to not being seen by the user.
Post Reply