diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 94b91ea73f..c0815aa402 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -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()->ClearSelection(); + ClearUndoRedoList(); + if( setProject ) { Schematic().SetProject( nullptr ); @@ -665,8 +669,6 @@ void SCH_EDIT_FRAME::OnImportProject( wxCommandEvent& aEvent ) return; } - m_toolManager->GetTool()->ClearSelection(); - importFile( dlg.GetPath(), pluginType ); RefreshCanvas();