]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix assert when changing the filter selection on a multiple selection wxGenericDirCtrl.
authorSteve Lamerton <steve.lamerton@gmail.com>
Wed, 22 Sep 2010 19:24:41 +0000 (19:24 +0000)
committerSteve Lamerton <steve.lamerton@gmail.com>
Wed, 22 Sep 2010 19:24:41 +0000 (19:24 +0000)
Because ExpandPaths selects the item we can simply grab a list of selected paths and then expand them all in the multiple selection case. The single selection case is unchanged.

Closes #12340

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

src/generic/dirctrlg.cpp

index eb633d9568268a592b13797c97ea5ee20ae708da..21e941eae52c24b8a5151efaddaf052c45f2431a 100644 (file)
@@ -1395,16 +1395,33 @@ void wxDirFilterListCtrl::OnSelFilter(wxCommandEvent& WXUNUSED(event))
 {
     int sel = GetSelection();
 
-    wxString currentPath = m_dirCtrl->GetPath();
+    if (m_dirCtrl->HasFlag(wxDIRCTRL_MULTIPLE))
+    {
+        wxArrayString paths;
+        m_dirCtrl->GetPaths(paths);
+
+        m_dirCtrl->SetFilterIndex(sel);
 
-    m_dirCtrl->SetFilterIndex(sel);
+        // If the filter has changed, the view is out of date, so
+        // collapse the tree.
+        m_dirCtrl->ReCreateTree();
+
+        // Expand and select the previously selected paths
+        for (unsigned int i = 0; i < paths.GetCount(); i++)
+        {
+            m_dirCtrl->ExpandPath(paths.Item(i));
+        }
+    }
+    else
+    {
+        wxString currentPath = m_dirCtrl->GetPath();
 
-    // If the filter has changed, the view is out of date, so
-    // collapse the tree.
-    m_dirCtrl->ReCreateTree();
+        m_dirCtrl->SetFilterIndex(sel);
+        m_dirCtrl->ReCreateTree();
 
-    // Try to restore the selection, or at least the directory
-    m_dirCtrl->ExpandPath(currentPath);
+        // Try to restore the selection, or at least the directory
+        m_dirCtrl->ExpandPath(currentPath);
+    }
 }
 
 void wxDirFilterListCtrl::FillFilterList(const wxString& filter, int defaultFilter)