From 330b1fd7339de77914672ae63a64d6bf284554f3 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 22 Mar 2022 17:41:50 +0000 Subject: [PATCH] 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 (cherry picked from commit 535ecb9b7ba0cdcc644d75cd124f63f541def8dc) --- eeschema/files-io.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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();