From fff95fa4e67d68e51513fe3fdff68057b0509059 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 22 Sep 2023 09:20:57 -0700 Subject: [PATCH] Disable non-KiCad import for project-mode Adds warning if project schematic contains data Fixes https://gitlab.com/kicad/code/kicad/-/issues/15570 (cherry picked from commit b837aa823c3010ba65dd7e7313a227d75a9a6d53) --- eeschema/files-io.cpp | 9 +++++++++ eeschema/menubar.cpp | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 4d6217444b..66c62a3cb9 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -590,6 +590,15 @@ void SCH_EDIT_FRAME::OnImportProject( wxCommandEvent& aEvent ) if( !AskToSaveChanges() ) return; + if( Schematic().RootScreen() && !Schematic().RootScreen()->Items().empty() ) + { + wxString msg = _( "This operation replaces the contents of the current project.\n\n" + "Do you want to proceed?" ); + + if( !IsOK( this, msg ) ) + return; + } + // Set the project location if none is set or if we are running in standalone mode bool setProject = Prj().GetProjectFullName().IsEmpty() || Kiface().IsSingle(); wxString path = wxPathOnly( Prj().GetProjectFullName() ); diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index 7302603727..edad542ea2 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -106,10 +106,14 @@ void SCH_EDIT_FRAME::doReCreateMenuBar() ACTION_MENU* submenuImport = new ACTION_MENU( false, selTool ); submenuImport->SetTitle( _( "Import" ) ); submenuImport->SetIcon( BITMAPS::import ); - submenuImport->Add( _( "Non-KiCad Schematic..." ), + + if( Kiface().IsSingle() ) + { + submenuImport->Add( _( "Non-KiCad Schematic..." ), _( "Replace current schematic sheet with one imported from another application" ), ID_IMPORT_NON_KICAD_SCH, BITMAPS::import_document ); + } submenuImport->Add( EE_ACTIONS::importFPAssignments, ACTION_MENU::NORMAL, _( "Footprint Assignments..." ) ); fileMenu->Add( submenuImport );