Crash/backtrace in wxTreeCtrl

[Env: ActiveState Python 2.2.1, wxPython 2.4.1.2, Win2000]

I'm finding some more issues with the wxTreeCtrl class when
wxTR_HIDE_ROOT is set. It seems that if you set this style, you can't
do a whole lot with the item returned by wxTreeCtrl.GetRootItem()
without wxPython dying. In particular, if you call ItemHasChildren(),
you get a C++ assertion failure. Not a problem, thinks I, I'll work
around it by calling GetFirstChild() and checking IsOK()... except
that method causes a hard crash.

I'm attaching a short example program.

Robin (if you're not gone yet)... ought I file this, or am I misusing
wxTreeCtrl?

Thanks.

treeTest.py (1.16 KB)

···

--
Tim Lesher <tim@lesher.ws>
http://www.lesher.ws

Tim Lesher wrote:

[Env: ActiveState Python 2.2.1, wxPython 2.4.1.2, Win2000]

I'm finding some more issues with the wxTreeCtrl class when
wxTR_HIDE_ROOT is set. It seems that if you set this style, you can't
do a whole lot with the item returned by wxTreeCtrl.GetRootItem()
without wxPython dying. In particular, if you call ItemHasChildren(),
you get a C++ assertion failure. Not a problem, thinks I, I'll work
around it by calling GetFirstChild() and checking IsOK()... except
that method causes a hard crash.

I'm attaching a short example program.

Robin (if you're not gone yet)...

You've still got me for a few hours.

ought I file this, or am I misusing
wxTreeCtrl?

Apparently. The exception you are getting comes from an explicit check that the item you are trying to get the children of is not a virtual (hidden) root. There isn't an explicit check like that in GetFirstChild but I expect that it is the same problem. Interestingly it appears that the crash actually happens in the MS API TreeView_GetChild...

Looks like you will have to keep track of your top level items yourself.

···

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

The perplexing thing is that most of the problems I'm running into
with root-hidden tree controls happen only on Windows, due to passing
invalid tree item handles (those that represent the 'virtual root' to
the native tree control. This is perplexing because MSW appears to be
the one platform that natively supports hidden root items (i.e., the
whole virtual root mechanism doesn't need to be used on MSW).

Maybe I'll take it up with Julian... ISTM that for the MSW port, the
virtual root mechanism doesn't need to be used at all, and using the
native support would eliminate all these issues.

I'll research it over the holidays, if I get time.

···

On Wed, Jul 02, 2003 at 02:43:17PM -0700, Robin Dunn wrote:

>ought I file this, or am I misusing
>wxTreeCtrl?

Apparently. The exception you are getting comes from an explicit check
that the item you are trying to get the children of is not a virtual
(hidden) root. There isn't an explicit check like that in
GetFirstChild but I expect that it is the same problem. Interestingly
it appears that the crash actually happens in the MS API
TreeView_GetChild...

Looks like you will have to keep track of your top level items yourself.

--
Tim Lesher <tim@lesher.ws>
http://www.lesher.ws