]> git.saurik.com Git - wxWidgets.git/commitdiff
Never collapse invisible root item in generic wxDataViewCtrl.
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 6 Nov 2012 16:50:56 +0000 (16:50 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 6 Nov 2012 16:50:56 +0000 (16:50 +0000)
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

src/generic/datavgen.cpp

index fb5c0a1159fac6843ba64004fa010fe13cfcdab2..06b045c78b6bbcc96ac4bdae1e778b4c9cf8a358 100644 (file)
@@ -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);