Fix renaming of files in the project tree

We must add the new node for the new file in the new directory,
not in the original root directory. The file watcher will also
delete the old node, so there is no point in renaming the file.

Fixes: lp:1852357
* https://bugs.launchpad.net/kicad/+bug/1852357
This commit is contained in:
Ian McInerney 2019-11-16 01:35:48 +00:00
parent 64e094f211
commit 2fc5e6c79f
2 changed files with 3 additions and 3 deletions

View File

@ -897,6 +897,7 @@ void TREE_PROJECT_FRAME::OnFileSystemEvent( wxFileSystemWatcherEvent& event )
case wxFSW_EVENT_RENAME :
{
const wxFileName& newpath = event.GetNewPath();
wxString newdir = newpath.GetPath();
wxString newfn = newpath.GetFullPath();
while( kid.IsOk() )
@ -912,7 +913,8 @@ void TREE_PROJECT_FRAME::OnFileSystemEvent( wxFileSystemWatcherEvent& event )
kid = m_TreeProject->GetNextChild( root_id, cookie );
}
AddItemToTreeProject( newfn, root_id, false );
wxTreeItemId newroot_id = findSubdirTreeItem( newdir );
AddItemToTreeProject( newfn, newroot_id, false );
}
break;
}

View File

@ -120,8 +120,6 @@ bool TREEPROJECT_ITEM::Rename( const wxString& name, bool check )
return false;
}
SetFileName( newFile );
return true;
}