]> git.saurik.com Git - wxWidgets.git/commitdiff
Reset sorting column in generic wxDataViewCtrl properly.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 21 Apr 2013 17:18:44 +0000 (17:18 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 21 Apr 2013 17:18:44 +0000 (17:18 +0000)
We could keep using the column previously used for sorting even after
UnsetAsSortKey() was called on it. Ensure that this doesn't happen by
resetting the owner wxDataViewCtrl sort column index too.

Closes #15160.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73834 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/generic/dataview.h
src/generic/datavgen.cpp

index 70ae97ca0ad2c80b1a0258ef35592d6e342e1933..fa8ad417c2f61e335b11ce5ae67eb61363ec507d 100644 (file)
@@ -70,7 +70,7 @@ public:
 
     virtual bool IsSortKey() const { return m_sort; }
 
-    virtual void UnsetAsSortKey() { m_sort = false; UpdateDisplay(); }
+    virtual void UnsetAsSortKey();
 
     virtual void SetSortOrder(bool ascending);
 
index def4fb5877478b7f13170d42e6f05da2070d84ce..2334084bcd7d32e17f351db61f70bdbfbf3b74a1 100644 (file)
@@ -161,6 +161,16 @@ void wxDataViewColumn::UpdateDisplay()
     }
 }
 
+void wxDataViewColumn::UnsetAsSortKey()
+{
+    m_sort = false;
+
+    if ( m_owner )
+        m_owner->SetSortingColumnIndex(wxNOT_FOUND);
+
+    UpdateDisplay();
+}
+
 void wxDataViewColumn::SetSortOrder(bool ascending)
 {
     if ( !m_owner )
@@ -613,26 +623,33 @@ public:
     {
         g_model = GetModel();
 
-        // Avoid sorting while the window is frozen, this allows to quickly add
-        // many items without resorting after each addition and only resort
-        // them all at once when the window is finally thawed, see above.
-        if ( IsFrozen() )
-        {
-            g_column = SortColumn_OnThaw;
-            return;
-        }
-
         wxDataViewColumn* col = GetOwner()->GetSortingColumn();
         if( !col )
         {
             if (g_model->HasDefaultCompare())
-                g_column = SortColumn_Default;
+            {
+                // See below for the explanation of IsFrozen() test.
+                if ( IsFrozen() )
+                    g_column = SortColumn_OnThaw;
+                else
+                    g_column = SortColumn_Default;
+            }
             else
                 g_column = SortColumn_None;
 
             g_asending = true;
             return;
         }
+
+        // Avoid sorting while the window is frozen, this allows to quickly add
+        // many items without resorting after each addition and only resort
+        // them all at once when the window is finally thawed, see above.
+        if ( IsFrozen() )
+        {
+            g_column = SortColumn_OnThaw;
+            return;
+        }
+
         g_column = col->GetModelColumn();
         g_asending = col->IsSortOrderAscending();
     }