Don't leave dangling pointers to old document when importing.

This goes for both selection pointers and undo/redo pointers.

Fixes https://gitlab.com/kicad/code/kicad/issues/10145
This commit is contained in:
Jeff Young 2022-03-22 17:41:50 +00:00
parent 3271b43d4b
commit 535ecb9b7b
1 changed files with 4 additions and 2 deletions

View File

@ -632,6 +632,10 @@ void SCH_EDIT_FRAME::OnImportProject( wxCommandEvent& aEvent )
if( dlg.ShowModal() == wxID_CANCEL )
return;
// Don't leave dangling pointers to previously-opened document.
m_toolManager->GetTool<EE_SELECTION_TOOL>()->ClearSelection();
ClearUndoRedoList();
if( setProject )
{
Schematic().SetProject( nullptr );
@ -665,8 +669,6 @@ void SCH_EDIT_FRAME::OnImportProject( wxCommandEvent& aEvent )
return;
}
m_toolManager->GetTool<EE_SELECTION_TOOL>()->ClearSelection();
importFile( dlg.GetPath(), pluginType );
RefreshCanvas();