[wxPython] tree control coredump wxpython 2.3.3.1

I keep getting a crash when running my application that contains a
wxtreectrl.

I build this treectrl as the user opens a new window in my application and
this works fine. When the user double clicks on a node of the tree, the
treectrl is rebuilt by first calling the DeleteAllItems() method and then
building another tree. This works most of the time but every so often when
double clicking on a node the application crashes. The crash seems to occur
after it has rebuilt the new tree so I don't understand what I could have
done wrong?

I first thought that it was the version of wxpython so upgraded to the
latest release (2.3.3.1) and still the same problem.

Does anyone have any ideas on this?

Finbarr

It _sounds_ like an event is referencing an already-destroyed tree item. When a handler tries to process that it would get an exception of some type which might cause a "crash". I'd suggest logging the start and end of each handler and seeing which handler is active when the app crashes, quite likely there will be an event showing up after you've finished your double-click-handler but before anything else happens.

BTW: "crash" is pretty generic, do you mean you get a Python exception that forces the app to exit, a wxPython Assert that stops the program, a silent exit of the entire application, or a memory-access violation (or similar) low-level exception which pops up a windows "your application did something naughty" dialog.

HTH,
Mike

Finbarr O'Keeffe wrote:

···

I keep getting a crash when running my application that contains a
wxtreectrl.

I build this treectrl as the user opens a new window in my application and
this works fine. When the user double clicks on a node of the tree, the
treectrl is rebuilt by first calling the DeleteAllItems() method and then
building another tree. This works most of the time but every so often when
double clicking on a node the application crashes. The crash seems to occur
after it has rebuilt the new tree so I don't understand what I could have
done wrong?

I first thought that it was the version of wxpython so upgraded to the
latest release (2.3.3.1) and still the same problem.

Does anyone have any ideas on this?

Finbarr

Ignore that BTW, I'd missed "coredump" in the subject line (which I think is a Linux version of a memory-access violation or the like).

Sorry,
Mike

Mike C. Fletcher wrote:

···

BTW: "crash" is pretty generic, do you mean you get a Python exception that forces the app to exit, a wxPython Assert that stops the program, a silent exit of the entire application, or a memory-access violation (or similar) low-level exception which pops up a windows "your application did something naughty" dialog.
...

Finbarr O'Keeffe wrote:

I keep getting a crash when running my application that contains a
wxtreectrl.

I build this treectrl as the user opens a new window in my application and
this works fine. When the user double clicks on a node of the tree, the
treectrl is rebuilt by first calling the DeleteAllItems() method and then
building another tree. This works most of the time but every so often when
double clicking on a node the application crashes. The crash seems to occur
after it has rebuilt the new tree so I don't understand what I could have
done wrong?

I first thought that it was the version of wxpython so upgraded to the
latest release (2.3.3.1) and still the same problem.

You don't want to add more tree nodes in the same event handler that does a DeleteAllItems because it does some cleanup in idle time. If you add the new nodes later then it will work fine. The wxCallAfter function can be helpful here.

···

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

Does that apply to using only DeleteAllItems, or any time you delete and
add items? Could you expound on this a little. I don't quite
understand. We are also getting segfaults using tree controls and I
haven't been able to pin it down yet.

Thanks.

···

On Tue, 08 Oct 2002 15:21:51 -0700 Robin Dunn <robin@alldunn.com> wrote:

Finbarr O'Keeffe wrote:
> I keep getting a crash when running my application that contains a
> wxtreectrl.
>
> I build this treectrl as the user opens a new window in my
> application and this works fine. When the user double clicks on a
> node of the tree, the treectrl is rebuilt by first calling the
> DeleteAllItems() method and then building another tree. This works
> most of the time but every so often when double clicking on a node
> the application crashes. The crash seems to occur after it has
> rebuilt the new tree so I don't understand what I could have done
> wrong?
>
> I first thought that it was the version of wxpython so upgraded to
> the latest release (2.3.3.1) and still the same problem.
>

You don't want to add more tree nodes in the same event handler that
does a DeleteAllItems because it does some cleanup in idle time. If
you add the new nodes later then it will work fine. The wxCallAfter
function can be helpful here.

--
Ken Dowling

Kenneth J. Dowling wrote:

···

On Tue, 08 Oct 2002 15:21:51 -0700 > Robin Dunn <robin@alldunn.com> wrote:

You don't want to add more tree nodes in the same event handler that does a DeleteAllItems because it does some cleanup in idle time. If
you add the new nodes later then it will work fine. The wxCallAfter function can be helpful here.

Does that apply to using only DeleteAllItems, or any time you delete and
add items? Could you expound on this a little. I don't quite
understand. We are also getting segfaults using tree controls and I
haven't been able to pin it down yet.

As far as I know it is only DeleteAllItems.

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