wxTreeCtrl checking for valid IDs

M

Martin Drautzburg

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top