tree_project_frame: in the wxFileSystemWatcherEvent event avoid adding the project

filename in tree list, because it is always the root item.
(The previous code was not taking into account the tree list root item)

Fixes #4460
https://gitlab.com/kicad/code/kicad/issues/4460
This commit is contained in:
jean-pierre charras 2020-05-16 13:05:53 +02:00
parent 92ce7caf9a
commit 44ea281210
1 changed files with 16 additions and 7 deletions

View File

@ -1044,12 +1044,21 @@ void TREE_PROJECT_FRAME::OnFileSystemEvent( wxFileSystemWatcherEvent& event )
kid = m_TreeProject->GetNextChild( root_id, cookie ); kid = m_TreeProject->GetNextChild( root_id, cookie );
} }
// Add the new item only if it is not the current project file (root item).
// Remember: this code is called by a wxFileSystemWatcherEvent event, and not always
// called after an actual file rename, and the cleanup code does not explore the
// root item, because it cannot be renamed by the user.
TREEPROJECT_ITEM* rootData = GetItemIdData( root_id );
if( newfn != rootData->GetFileName() )
{
wxTreeItemId newroot_id = findSubdirTreeItem( newdir ); wxTreeItemId newroot_id = findSubdirTreeItem( newdir );
wxTreeItemId newitem = AddItemToTreeProject( newfn, newroot_id ); wxTreeItemId newitem = AddItemToTreeProject( newfn, newroot_id );
// If the item exists, select it // If the item exists, select it
if( newitem.IsOk() ) if( newitem.IsOk() )
m_TreeProject->SelectItem( newitem ); m_TreeProject->SelectItem( newitem );
}
m_isRenaming = false; m_isRenaming = false;
} }