From: Vadim Zeitlin Date: Tue, 6 Nov 2012 16:50:56 +0000 (+0000) Subject: Never collapse invisible root item in generic wxDataViewCtrl. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/ddcc73a7626a3ae9d2fd2399d0993b48b1d10d60 Never collapse invisible root item in generic wxDataViewCtrl. Since the changes of r72325, the root item could be collapsed and marked as not having any children but this was wrong because no items could be added to it after this. Just ignore any attempts to collapse it. Closes #14801. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72905 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index fb5c0a1159..06b045c78b 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -347,7 +347,7 @@ public: static wxDataViewTreeNode* CreateRootNode() { wxDataViewTreeNode *n = new wxDataViewTreeNode(NULL, wxDataViewItem()); - n->SetHasChildren(true); + n->m_branchData = new BranchNodeData; n->m_branchData->open = true; return n; } @@ -416,6 +416,11 @@ public: void ToggleOpen() { + // We do not allow the (invisible) root node to be collapsed because + // there is no way to expand it again. + if ( !m_parent ) + return; + wxCHECK_RET( m_branchData != NULL, "can't open leaf node" ); int sum = 0; @@ -446,6 +451,11 @@ public: void SetHasChildren(bool has) { + // The invisible root item always has children, so ignore any attempts + // to change this. + if ( !m_parent ) + return; + if ( !has ) { wxDELETE(m_branchData);