[ wxwindows-Bugs-1765566 ] wxTreeCtrl::ExpandAll causing assertion
error
SourceForge.net
noreply at sourceforge.net
Wed Aug 15 06:08:35 PDT 2007
Bugs item #1765566, was opened at 2007-08-01 18:04
Message generated for change (Comment added) made by vadz
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1765566&group_id=9863
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: Trivial
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Martin (spacedude666)
Assigned to: Nobody/Anonymous (nobody)
Summary: wxTreeCtrl::ExpandAll causing assertion error
Initial Comment:
When a tree control is created with the wxTR_HIDE_ROOT option and the wxTreeCtrl::ExpandAll function is called the following assertion error occurs:
\wxWidgets-2.8.3\src\msw\treectrl.cpp(1641): assert "!IsHiddenRoot(item)" failed in wxTreeCtrl::DoExpand(): Can't expand/collapse hidden root node!
The function still performs as expected but this assertion is clearly not necessary when calling the ExpandAll function. I suspect the ExpandAll function needs to be modified such that it doesn't try to expand or collapse the root if it is hidden.
Note: I posted this query on the forum a while ago but got no useful response (http://wxforum.shadonet.com/viewtopic.php?t=14528&highlight=)
----------------------------------------------------------------------
>Comment By: Vadim Zeitlin (vadz)
Date: 2007-08-15 15:08
Message:
Logged In: YES
user_id=71618
Originator: NO
Should be fixed in the trunk now.
----------------------------------------------------------------------
Comment By: Christian Buhtz (moonkid)
Date: 2007-08-03 13:48
Message:
Logged In: YES
user_id=601949
Originator: NO
Yes, just create the patch against current SVN and submit it.
----------------------------------------------------------------------
Comment By: Martin (spacedude666)
Date: 2007-08-03 10:36
Message:
Logged In: YES
user_id=1506959
Originator: YES
I think you missed my reply to your initial message. The change I
suggested is the same, but as noted in my earlier message IsHiddenRoot is
not a member function of wxTreeCtrlBase but of wxTreeCtrl. I think the
problem can be solved by overriding the ExpandAllChildren function in
wxTreeCtrl. I think I have enough information to fix it myself now, should
I go ahead and do it and then submit it as a patch?
----------------------------------------------------------------------
Comment By: Christian Buhtz (moonkid)
Date: 2007-08-03 07:34
Message:
Logged In: YES
user_id=601949
Originator: NO
Is it so simple? :)
Just ask for HiddenRoot in ExpandAllChildren()
[code]
void wxTreeCtrlBase::ExpandAllChildren(const wxTreeItemId& item)
{
// expand this item first, this might result in its children being
added on
// the fly
if ( !IsHiddenRoot(item) )
Expand(item);
// then (recursively) expand all the children
wxTreeItemIdValue cookie;
for ( wxTreeItemId idCurr = GetFirstChild(item, cookie);
idCurr.IsOk();
idCurr = GetNextChild(item, cookie) )
{
ExpandAllChildren(idCurr);
}
}
[/code]
Do not change ExpandAll().
----------------------------------------------------------------------
Comment By: Martin (spacedude666)
Date: 2007-08-02 18:10
Message:
Logged In: YES
user_id=1506959
Originator: YES
Yes something like that would work I guess... Perhaps a simpler solution
would be to change from:
void wxTreeCtrlBase::ExpandAllChildren(const wxTreeItemId& item)
{
// expand this item first, this might result in its children being
added on
// the fly
Expand(item);
// then (recursively) expand all the children
....
to:
void wxTreeCtrlBase::ExpandAllChildren(const wxTreeItemId& item)
{
// expand this item first, this might result in its children being
added on
// the fly
if (!IsHiddenRoot(item))
Expand(item);
// then (recursively) expand all the children
....
However the IsHiddenRoot function is part of the derived class wxTreeCtrl
so wxTreeCtrlBase doesn't have access to it. Would it be sensible to make
ExpandAllChildren a virtual function and override it in wxTreeCtrl with the
new functionality?
----------------------------------------------------------------------
Comment By: Christian Buhtz (moonkid)
Date: 2007-08-02 17:27
Message:
Logged In: YES
user_id=601949
Originator: NO
Ok, the question is what should ExpandAll() do if the root is hidden?
It should expand all first-level-childs and their childs, I am right?
Then the code should be like this:
[code]
void wxTreeCtrlBase::ExpandAll()
{
if ( IsEmpty() )
return;
if ( IsHidenRoot(GetRootItem()) )
{
wxTreeItemIdValue idCookie;
wxTreeItemId idChild;
for (idChild = GetFirstChild(GetRootItem(), idCookie);
idChild.IsOk();
idChild = GetNextChild(GetRootItem(), idCookie))
ExpandAllChildren(idChild);
}
else
{
ExpandAllChildren(GetRootItem());
}
}
[/code]
I will create and test a patch for it is ok!
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1765566&group_id=9863
More information about the wx-dev
mailing list