Destroying panel crashes my app

Hi,

    In 2.8.0.1 when I destroy a panel my app crashes. It happened
before in 2.7 series but that time Robin told me to use wx.CallAfter
and that worked. But it doesn't work anymore. The strange thing is
that I have two buttons on that panel that makes it destroy. OK and
Cancel. When I click OK I do something and destroy the panel and it
works normally. When I click Cancel I just destroy the panel. But it
makes my app crash. I really wonder why this happens.

Hi,

basically you try to destroy the buttons parent. No child should destroy its parent.
The way to avoid this is to delegate the destruction of the parent to a third party (CallAfter a method binded to let’s say the parent of the panel that needs to be destroyed)

I think that when a child destroys its parent the C++ objects under the hood get in a weird state that will bring your app crashing.

Peter

···

On 1/20/07, Murat Erten murerten@gmail.com wrote:

Hi,

In [2.8.0.1](http://2.8.0.1) when I destroy a panel my app crashes. It happened

before in 2.7 series but that time Robin told me to use wx.CallAfter
and that worked. But it doesn’t work anymore. The strange thing is

that I have two buttons on that panel that makes it destroy. OK and
Cancel. When I click OK I do something and destroy the panel and it
works normally. When I click Cancel I just destroy the panel. But it
makes my app crash. I really wonder why this happens.


There is NO FATE, we are the creators.

Hi Peter,

    Thank you for your suggestion. I tried destroying panel from
parent. It didn't work. But I solved the problem by destroying the
cancel button before the panel. I think there is a bug in 2.7 and
after versions of wxPython MSW.

Murat

···

2007/1/20, Peter Damoc <pdamoc@gmail.com>:

On 1/20/07, Murat Erten <murerten@gmail.com> wrote:

> Hi,
>
> In 2.8.0.1 when I destroy a panel my app crashes. It happened
> before in 2.7 series but that time Robin told me to use wx.CallAfter
> and that worked. But it doesn't work anymore. The strange thing is
> that I have two buttons on that panel that makes it destroy. OK and
> Cancel. When I click OK I do something and destroy the panel and it
> works normally. When I click Cancel I just destroy the panel. But it
> makes my app crash. I really wonder why this happens.

Hi,

basically you try to destroy the buttons parent. No child should destroy its
parent.
The way to avoid this is to delegate the destruction of the parent to a
third party (CallAfter a method binded to let's say the parent of the panel
that needs to be destroyed)

I think that when a child destroys its parent the C++ objects under the hood
get in a weird state that will bring your app crashing.

Peter
--
There is NO FATE, we are the creators.