consitent crash

I am able to crash python every time I run the project I am working on.
(running on WinXP pro, python 2.4.3 and wxpython 2.6.3.3)
It seems to happen when I run the following code:

    def OnChangeState(self,event):
        print "OnChangeState"
        (frame,sessionstate,queue)=event.data
        (parent,label,uibase,ShowElements,Events)=frame.params
        for i in range(self.frame.nb.GetPageCount()):
            if self.frame.nb.GetPage(i)==frame:
                #print "Updating page #:%i"%i
                self.frame.nb.DeletePage(i)
               
window=self.frame.nb.makeTabPanel(label,uibase,sessionstate,ShowElements,Events)
                self.frame.nb.InsertPage(i,window, label)
                self.frame.nb.SetSelection(i)
                queue.put(window)

to delete a notebook tab filled with XRC data and replace it with another.

Can someone please tell me what I am doing wrong?

best regards,

Paul Sijben

···

--
Paul Sijben tel: +31334566488
Eemvalley Systems & Technology fax: +31334557523
the Netherlands http://eemvalley.com

Paul Sijben wrote:

I am able to crash python every time I run the project I am working on.
(running on WinXP pro, python 2.4.3 and wxpython 2.6.3.3)
It seems to happen when I run the following code:

    def OnChangeState(self,event):
        print "OnChangeState"
        (frame,sessionstate,queue)=event.data
        (parent,label,uibase,ShowElements,Events)=frame.params
        for i in range(self.frame.nb.GetPageCount()):
            if self.frame.nb.GetPage(i)==frame:
                #print "Updating page #:%i"%i
                self.frame.nb.DeletePage(i)
               window=self.frame.nb.makeTabPanel(label,uibase,sessionstate,ShowElements,Events)
                self.frame.nb.InsertPage(i,window, label)
                self.frame.nb.SetSelection(i)
                queue.put(window)

to delete a notebook tab filled with XRC data and replace it with another.

Can someone please tell me what I am doing wrong?

Can you tell if it is crashing on one of the lines above, or sometime after this event handler is run? It's possible that there could still be pending events for the page window, and it is getting Destroyed too soon. So instead of DeletePage, try something like this instead:

  page = self.frame.nb.GetPage(i)
  self.frame.nb.RemovePage(i)
  wx.CallAfter(page.Destroy)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

I found that the panel is updated but that the whole updating of it dies
on the crash.

I managed to keep the crash at bay for a while by removing debugging
prints, don't know how that could help.
But now it is back I tried the code you provided but I am getting the
same crash.

Maybe I should have mentioned, the crash does not give a python
backtrace, it seems to be a C-crash, I get the Microsoft window asking
it I want to report this to Microsoft.
The information that window provides is very unhelpful. I can not seem
to get a gist which dll actually holds the code code that caused the
crash. Is there a way to get that info without installing the whole
Microdot developer suite?

Robin Dunn wrote:

···

Paul Sijben wrote:

I am able to crash python every time I run the project I am working on.
(running on WinXP pro, python 2.4.3 and wxpython 2.6.3.3)
It seems to happen when I run the following code:

    def OnChangeState(self,event):
        print "OnChangeState"
        (frame,sessionstate,queue)=event.data
        (parent,label,uibase,ShowElements,Events)=frame.params
        for i in range(self.frame.nb.GetPageCount()):
            if self.frame.nb.GetPage(i)==frame:
                #print "Updating page #:%i"%i
                self.frame.nb.DeletePage(i)
              
window=self.frame.nb.makeTabPanel(label,uibase,sessionstate,ShowElements,Events)

                self.frame.nb.InsertPage(i,window, label)
                self.frame.nb.SetSelection(i)
                queue.put(window)

to delete a notebook tab filled with XRC data and replace it with
another.

Can someone please tell me what I am doing wrong?

Can you tell if it is crashing on one of the lines above, or sometime
after this event handler is run? It's possible that there could still
be pending events for the page window, and it is getting Destroyed too
soon. So instead of DeletePage, try something like this instead:

    page = self.frame.nb.GetPage(i)
    self.frame.nb.RemovePage(i)
    wx.CallAfter(page.Destroy)

--
Paul Sijben tel: +31334566488
Eemvalley Systems & Technology fax: +31334557523
the Netherlands http://eemvalley.com

OK I solved it. You mentioning about the events to deleted objects set
my throuhgs onm the right track. I was posting the event to the panel I
was killing. the changed code is below.

        page = self.frame.nb.GetPage(i)

        if page==frame:

            print "Updating page #:%i"%i               

            #self.frame.nb.RemovePage(i)

            wx.CallAfter(page.Destroy)

            self.frame.nb.DeletePage(i)

window=self.frame.nb.makeTabPanel(label,uibase,sessionstate,ShowElements,Events)

            window.myParent=self

            print "inserting page"

            self.frame.nb.InsertPage(i,window, label)

            print" setting selection"

            self.frame.nb.SetSelection(i)

            print "putting queue"

            queue.put(window)

    print "returning"

this leads to no more crashes but the following output on the console.

putting queue

returning

Traceback (most recent call last):

File “C:\Python24\Lib\site-packages\wx-2.6-msw-ansi\wx_core.py”,
line 13539,

in

lambda event: event.callable(*event.args, **event.kw) )

File “C:\Python24\Lib\site-packages\wx-2.6-msw-ansi\wx_core.py”,
line 8108, i

n Destroy

return _core_.Window_Destroy(*args, **kwargs)

TypeError: argument number 1: a ‘wxWindow *’ is expected,
'_wxPyDeadObject(wxPyt

hon wrapper for DELETED TabPanel object! (The C++ object no longer
exists.))’ is

received

How can I get rid of that?

best regards,

Paul Sijben

Paul Sijben wrote:

···
-- Paul Sijben tel: +31334566488
Eemvalley Systems & Technology fax: +31334557523
the Netherlands

http://eemvalley.com

never mind. It seems sorted now with the code below.

page = self.frame.nb.GetPage(i)

        if page==frame:

            #print "Updating page #:%i"%i

            wx.CallAfter(page.Destroy)

            self.frame.nb.RemovePage(i)

            #self.frame.nb.DeletePage(i)

window=self.frame.nb.makeTabPanel(label,uibase,sessionstate,ShowElements,Events)

            window.myParent=self

            #print "inserting page"

            self.frame.nb.InsertPage(i,window, label)

            #print" setting selection"

            self.frame.nb.SetSelection(i)

            #print "putting queue"

            queue.put(window)

Paul Sijben wrote:

···
-- Paul Sijben tel: +31334566488
Eemvalley Systems & Technology fax: +31334557523
the Netherlands

http://eemvalley.com

-- Paul Sijben tel: +31334566488
Eemvalley Systems & Technology fax: +31334557523
the Netherlands

http://eemvalley.com

According to the docs, nb.DeletePage() destroys the page and its
children, and nb.RemovePage() doesn't (you may want to move notebook
tabs).

- Josiah

···

Paul Sijben <sijben@eemvalley.com> wrote:

never mind. It seems sorted now with the code below.

page = self.frame.nb.GetPage(i)
            if page==frame:
                #print "Updating page #:%i"%i
                wx.CallAfter(page.Destroy)
                self.frame.nb.RemovePage(i)

                #self.frame.nb.DeletePage(i)
               
window=self.frame.nb.makeTabPanel(label,uibase,sessionstate,ShowElements,Events)
                window.myParent=self
                #print "inserting page"
                self.frame.nb.InsertPage(i,window, label)
                #print" setting selection"
                self.frame.nb.SetSelection(i)
                #print "putting queue"
                queue.put(window)

Paul Sijben wrote:
> OK I solved it. You mentioning about the events to deleted objects set
> my throuhgs onm the right track. I was posting the event to the panel
> I was killing. the changed code is below.
>
> page = self.frame.nb.GetPage(i)
> if page==frame:
> print "Updating page #:%i"%i
> #self.frame.nb.RemovePage(i)
> wx.CallAfter(page.Destroy)
> self.frame.nb.DeletePage(i)
>
> window=self.frame.nb.makeTabPanel(label,uibase,sessionstate,ShowElements,Events)
> window.myParent=self
> print "inserting page"
> self.frame.nb.InsertPage(i,window, label)
> print" setting selection"
> self.frame.nb.SetSelection(i)
> print "putting queue"
> queue.put(window)
> print "returning"
>
> this leads to no more crashes but the following output on the console.
>
>
> putting queue
> returning
> Traceback (most recent call last):
> File "C:\Python24\Lib\site-packages\wx-2.6-msw-ansi\wx\_core.py",
> line 13539,
> in <lambda>
> lambda event: event.callable(*event.args, **event.kw) )
> File "C:\Python24\Lib\site-packages\wx-2.6-msw-ansi\wx\_core.py",
> line 8108, i
> n Destroy
> return _core_.Window_Destroy(*args, **kwargs)
> TypeError: argument number 1: a 'wxWindow *' is expected,
> '_wxPyDeadObject(wxPyt
> hon wrapper for DELETED TabPanel object! (The C++ object no longer
> exists.))' is
> received
>
> How can I get rid of that?
>
> best regards,
>
> Paul Sijben
>
> Paul Sijben wrote:
>> I found that the panel is updated but that the whole updating of it dies
>> on the crash.
>>
>> I managed to keep the crash at bay for a while by removing debugging
>> prints, don't know how that could help.
>> But now it is back I tried the code you provided but I am getting the
>> same crash.
>>
>> Maybe I should have mentioned, the crash does not give a python
>> backtrace, it seems to be a C-crash, I get the Microsoft window asking
>> it I want to report this to Microsoft.
>> The information that window provides is very unhelpful. I can not seem
>> to get a gist which dll actually holds the code code that caused the
>> crash. Is there a way to get that info without installing the whole
>> Microdot developer suite?
>>
>> Robin Dunn wrote:
>>
>>> Paul Sijben wrote:
>>>
>>>> I am able to crash python every time I run the project I am working on.
>>>> (running on WinXP pro, python 2.4.3 and wxpython 2.6.3.3)
>>>> It seems to happen when I run the following code:
>>>>
>>>> def OnChangeState(self,event):
>>>> print "OnChangeState"
>>>> (frame,sessionstate,queue)=event.data
>>>> (parent,label,uibase,ShowElements,Events)=frame.params
>>>> for i in range(self.frame.nb.GetPageCount()):
>>>> if self.frame.nb.GetPage(i)==frame:
>>>> #print "Updating page #:%i"%i
>>>> self.frame.nb.DeletePage(i)
>>>>
>>>> window=self.frame.nb.makeTabPanel(label,uibase,sessionstate,ShowElements,Events)
>>>>
>>>> self.frame.nb.InsertPage(i,window, label)
>>>> self.frame.nb.SetSelection(i)
>>>> queue.put(window)
>>>>
>>>> to delete a notebook tab filled with XRC data and replace it with
>>>> another.
>>>>
>>>> Can someone please tell me what I am doing wrong?
>>>>
>>> Can you tell if it is crashing on one of the lines above, or sometime
>>> after this event handler is run? It's possible that there could still
>>> be pending events for the page window, and it is getting Destroyed too
>>> soon. So instead of DeletePage, try something like this instead:
>>>
>>> page = self.frame.nb.GetPage(i)
>>> self.frame.nb.RemovePage(i)
>>> wx.CallAfter(page.Destroy)
>>>
>>>
>>>
>>
>>
>
> --
> Paul Sijben tel: +31334566488
> Eemvalley Systems & Technology fax: +31334557523
> the Netherlands http://eemvalley.com
>

--
Paul Sijben tel: +31334566488
Eemvalley Systems & Technology fax: +31334557523
the Netherlands http://eemvalley.com