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
This commit is contained in:
parent
033428a32c
commit
9e48865ca1
@ -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();
|
||||
// If the filter has changed, the view is out of date, so
|
||||
// collapse the tree.
|
||||
m_dirCtrl->ReCreateTree();
|
||||
|
||||
// Try to restore the selection, or at least the directory
|
||||
m_dirCtrl->ExpandPath(currentPath);
|
||||
// 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();
|
||||
|
||||
m_dirCtrl->SetFilterIndex(sel);
|
||||
m_dirCtrl->ReCreateTree();
|
||||
|
||||
// Try to restore the selection, or at least the directory
|
||||
m_dirCtrl->ExpandPath(currentPath);
|
||||
}
|
||||
}
|
||||
|
||||
void wxDirFilterListCtrl::FillFilterList(const wxString& filter, int defaultFilter)
|
||||
|
Loading…
Reference in New Issue
Block a user