From c72fa1cd626f2fe078dd494d68b80cfd9b56f146 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 3 Dec 2010 12:40:15 +0000 Subject: [PATCH 1/1] Update the directory icon in wxGenericDirCtrl::ExpandDir(). Calling ExpandDir() to notify the control that a new item was added in a previously empty directory didn't work as wxTreeCtrl::SetItemHasChildren() wasn't called. Fix this by moving SetItemHasChildren() to ExpandDir() from OnExpandItem(), it must be always done and not just in response to an interactive action. Closes #12735. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66311 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/dirctrlg.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/generic/dirctrlg.cpp b/src/generic/dirctrlg.cpp index dbaaf19a54..0ee1c0b2f8 100644 --- a/src/generic/dirctrlg.cpp +++ b/src/generic/dirctrlg.cpp @@ -761,14 +761,9 @@ void wxGenericDirCtrl::OnExpandItem(wxTreeEvent &event) // ctor when wxTR_HIDE_ROOT was specified if (!m_rootId.IsOk()) - m_rootId = m_treeCtrl->GetRootItem(); ExpandDir(parentId); - if ( m_treeCtrl->GetChildrenCount(parentId, false) == 0 ) - { - m_treeCtrl->SetItemHasChildren(parentId, false); - } } void wxGenericDirCtrl::OnCollapseItem(wxTreeEvent &event ) @@ -892,6 +887,10 @@ void wxGenericDirCtrl::ExpandDir(wxTreeItemId parentId) filenames.Sort(wxDirCtrlStringCompareFunction); } + // Now we really know whether we have any children so tell the tree control + // about it. + m_treeCtrl->SetItemHasChildren(parentId, !dirs.empty() || !filenames.empty()); + // Add the sorted dirs size_t i; for (i = 0; i < dirs.GetCount(); i++) @@ -911,7 +910,7 @@ void wxGenericDirCtrl::ExpandDir(wxTreeItemId parentId) // assume that it does have children by default as it can take a long // time to really check for this (think remote drives...) // - // and if we're wrong, we'll correct it later in OnExpandItem() if + // and if we're wrong, we'll correct the icon later if // the user really tries to open this item m_treeCtrl->SetItemHasChildren(id); } -- 2.45.2