Deleted panel causes an error - "Couldn't retrieve information about list control item 2." / C++ object deleted

Hello to WxPython developers,

Did anyone ever encounter an issue where wxpython references a deleted object from the loop?

I have an application where I add and remove panels that contain controls for a frame - pretty standard form interface.

In very particular cases that I can reproduce in my app, where I create a new panel and then immediately delete it WxPython seems to reference deleted objects.

On Windows I get a message box with the following text:

“Couldn’t retrieve information about list control item 2.”

When I try to see the offending command with a debugger it seems it is generated by the WxPython Loop, after the panel deletion event has been processed. And this happens only in certain rare conditions where I changed the text in a text box before creating the new panel I am deleting, so I do not think this is something I am doing terribly wrong - although reproducible, it is very rare and not caught by the debugger during event processing and does not happen in other forms that are somewhat similar.

When executed on a Linux system, however, the system gives an error message on screen:

Traceback (most recent call last):
File “/home/work/Desktop/MISTtst/CDMLib.py”, line 841, in FrameEventHandler
if Exist(this_panel) and this_panel.isRow:
File “/home/work/anaconda/lib/python2.7/site-packages/wx-3.0-gtk2/wx/_core.py”, line 16708, in getattr
raise PyDeadObjectError(self.attrStr % self._name)
wx._core.PyDeadObjectError: The C++ part of the RowPanel object has been deleted, attribute access no longer allowed.

This indicates that something happens after deletion and may explain what happens on windows, yet may be separate.

Note that panel deletion is triggered by pressing a button on the panel and handling its event and exiting the function.

Does someone have any idea of what may be going on, or what should I look for?

I am not sure I can easily create a small simple application that reproduces this issue since it happens in very rare cases of a certain click and entry sequence. Yet I hope there is sufficient information here to give someone a clue.

Jacob

Hi Jacob,

if Exist(this_panel) and this_panel.isRow:

Are you deleting the panel in your event handler?

If you do you might want to move that to a method which is called by the event handler with e.g. wx.CallAfter.

You should be able to protect the above by doing:

if this_panel:
    if Exist(this_panel .... etc

See the explanation in the Phoenix doc for PyDeadObjectError:
http://wxpython.org/Phoenix/docs/html/MigrationGuide.html

Werner

···

On 8/26/2014 14:33, Jacob Barhak wrote:

Are you using .Destroy() or the python del?

···

On Tuesday, August 26, 2014 5:33:09 AM UTC-7, Jacob Barhak wrote:

Hello to WxPython developers,

Did anyone ever encounter an issue where wxpython references a deleted object from the loop?

I have an application where I add and remove panels that contain controls for a frame - pretty standard form interface.

In very particular cases that I can reproduce in my app, where I create a new panel and then immediately delete it WxPython seems to reference deleted objects.

On Windows I get a message box with the following text:

“Couldn’t retrieve information about list control item 2.”

When I try to see the offending command with a debugger it seems it is generated by the WxPython Loop, after the panel deletion event has been processed. And this happens only in certain rare conditions where I changed the text in a text box before creating the new panel I am deleting, so I do not think this is something I am doing terribly wrong - although reproducible, it is very rare and not caught by the debugger during event processing and does not happen in other forms that are somewhat similar.

When executed on a Linux system, however, the system gives an error message on screen:

Traceback (most recent call last):
File “/home/work/Desktop/MISTtst/CDMLib.py”, line 841, in FrameEventHandler
if Exist(this_panel) and this_panel.isRow:
File “/home/work/anaconda/lib/python2.7/site-packages/wx-3.0-gtk2/wx/_core.py”, line 16708, in getattr
raise PyDeadObjectError(self.attrStr % self._name)
wx._core.PyDeadObjectError: The C++ part of the RowPanel object has been deleted, attribute access no longer allowed.

This indicates that something happens after deletion and may explain what happens on windows, yet may be separate.

Note that panel deletion is triggered by pressing a button on the panel and handling its event and exiting the function.

Does someone have any idea of what may be going on, or what should I look for?

I am not sure I can easily create a small simple application that reproduces this issue since it happens in very rare cases of a certain click and entry sequence. Yet I hope there is sufficient information here to give someone a clue.

Jacob

Hi Nathan,

Destroy is being used, yet this is not the issue.

Werner got it right.

Jacob

···

Sent from my iPhone

On Aug 26, 2014, at 3:06 PM, Nathan McCorkle nmz787@gmail.com wrote:

Are you using .Destroy() or the python del?

On Tuesday, August 26, 2014 5:33:09 AM UTC-7, Jacob Barhak wrote:

Hello to WxPython developers,

Did anyone ever encounter an issue where wxpython references a deleted object from the loop?

I have an application where I add and remove panels that contain controls for a frame - pretty standard form interface.

In very particular cases that I can reproduce in my app, where I create a new panel and then immediately delete it WxPython seems to reference deleted objects.

On Windows I get a message box with the following text:

“Couldn’t retrieve information about list control item 2.”

When I try to see the offending command with a debugger it seems it is generated by the WxPython Loop, after the panel deletion event has been processed. And this happens only in certain rare conditions where I changed the text in a text box before creating the new panel I am deleting, so I do not think this is something I am doing terribly wrong - although reproducible, it is very rare and not caught by the debugger during event processing and does not happen in other forms that are somewhat similar.

When executed on a Linux system, however, the system gives an error message on screen:

Traceback (most recent call last):
File “/home/work/Desktop/MISTtst/CDMLib.py”, line 841, in FrameEventHandler
if Exist(this_panel) and this_panel.isRow:
File “/home/work/anaconda/lib/python2.7/site-packages/wx-3.0-gtk2/wx/_core.py”, line 16708, in getattr
raise PyDeadObjectError(self.attrStr % self._name)
wx._core.PyDeadObjectError: The C++ part of the RowPanel object has been deleted, attribute access no longer allowed.

This indicates that something happens after deletion and may explain what happens on windows, yet may be separate.

Note that panel deletion is triggered by pressing a button on the panel and handling its event and exiting the function.

Does someone have any idea of what may be going on, or what should I look for?

I am not sure I can easily create a small simple application that reproduces this issue since it happens in very rare cases of a certain click and entry sequence. Yet I hope there is sufficient information here to give someone a clue.

Jacob

You received this message because you are subscribed to a topic in the Google Groups “wxPython-users” group.

To unsubscribe from this topic, visit https://groups.google.com/d/topic/wxpython-users/4O4kpLl4Vps/unsubscribe.

To unsubscribe from this group and all its topics, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Hi Werner,

You have the correct solution. Using wx.CallAfter seems to fix things in both Windows and Linux. I can no longer reconstruct this error.

On top of this, I was able to fix another issue that was bothering me for a whole using your advice.

Good observation.

You got a place in my hall of fame.

         Jacob

···

Sent from my iPhone

On Aug 26, 2014, at 9:18 AM, Werner <wernerfbd@gmx.ch> wrote:

Hi Jacob,

On 8/26/2014 14:33, Jacob Barhak wrote:

if Exist(this_panel) and this_panel.isRow:

Are you deleting the panel in your event handler?

If you do you might want to move that to a method which is called by the event handler with e.g. wx.CallAfter.

You should be able to protect the above by doing:

if this_panel:
  if Exist(this_panel .... etc

See the explanation in the Phoenix doc for PyDeadObjectError:
wxPython Project Phoenix Migration Guide — wxPython Phoenix 4.2.3a1 documentation

Werner

--
You received this message because you are subscribed to a topic in the Google Groups "wxPython-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wxpython-users/4O4kpLl4Vps/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.