wxTreeCtrl checking for valid IDs

Martin Drautzburg martin.drautzburg at web.de
Mon Dec 27 18:37:36 EST 2004


I have run across a weired problem: I am using a wxTreeCtrl with a
model for each tree node. The tree expands "lazily" and each time a
node is expanded, its children (Views) are completely rebuilt,
creating new IDs. The children register their respecive models using
two self written classes "Model" and "View". I should note, that when
collapsing, I delete children in a brute-force way, using
CollapseAndReset().

Each time a node is collapsed and expanded old nodes are deleted and
new nodes (Views) are created, but the old ones are still registered
as views for their models.  When such a model issues a self.changed()
all their views try to update themselves. But some of them are already
gone and no longer tree nodes of my tree. Trying to update their
labels gives me a SIGSEGV.

I had similar problem with other widgets, but there I get a
wx._core.PyDeadObjectError which I could handle easily. But the tree
just gives me a SIGSEGV.

So I have two options: either delete tree nodes more gently doing all
the cleanup work, or figure out if a tree item is still part of the
tree before the SIGSEGV gets me. The first will definitely require
some sort of tree traversal, the second maybe not. But I haven't found
a way to do this.

If I am totally off the paved road, please tell me so.





More information about the Python-list mailing list