From 9e48865ca16388a708a24d0a83cc09bbadfebd84 Mon Sep 17 00:00:00 2001 From: Steve Lamerton Date: Wed, 22 Sep 2010 19:24:41 +0000 Subject: [PATCH] Fix assert when changing the filter selection on a multiple selection wxGenericDirCtrl. 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 | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/generic/dirctrlg.cpp b/src/generic/dirctrlg.cpp index eb633d9568..21e941eae5 100644 --- a/src/generic/dirctrlg.cpp +++ b/src/generic/dirctrlg.cpp @@ -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) -- 2.45.2