diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index dcfaaba0fc..7be4665be3 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -50,6 +50,7 @@ #include #include #include +#include bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, @@ -755,12 +756,9 @@ bool SCH_EDIT_FRAME::doAutoSave() bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType ) { wxString fullFileName( aFileName ); - - SCH_PLUGIN::SCH_PLUGIN_RELEASER pi; wxString projectpath; wxFileName newfilename; SCH_SHEET_LIST sheetList( g_RootSheet ); - SCH_SCREENS schematic; switch( (SCH_IO_MGR::SCH_FILE_T) aFileType ) { @@ -779,9 +777,30 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType ) try { - pi.set( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_EAGLE ) ); + delete g_RootSheet; + g_RootSheet = nullptr; + SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_EAGLE ) ); g_RootSheet = pi->Load( fullFileName, &Kiway() ); + + // Eagle sheets do not use a worksheet frame by default, so set it to an empty one + WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance(); + pglayout.SetEmptyLayout(); + + BASE_SCREEN::m_PageLayoutDescrFileName = "empty.kicad_wks"; + wxFileName layoutfn( Kiway().Prj().GetProjectPath(), + BASE_SCREEN::m_PageLayoutDescrFileName ); + wxFile layoutfile; + + if( layoutfile.Create( layoutfn.GetFullPath() ) ) + { + layoutfile.Write( WORKSHEET_LAYOUT::EmptyLayout() ); + layoutfile.Close(); + } + + SaveProjectSettings( false ); + + projectpath = Kiway().Prj().GetProjectPath(); newfilename.SetPath( Prj().GetProjectPath() ); newfilename.SetName( Prj().GetProjectName() ); @@ -796,7 +815,8 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType ) GetScreen()->SetModify(); UpdateFileHistory( fullFileName ); - schematic.UpdateSymbolLinks(); // Update all symbol library links for all sheets. + SCH_SCREENS schematic; + schematic.UpdateSymbolLinks(); // Update all symbol library links for all sheets. // Ensure the schematic is fully segmented on first display BreakSegmentsOnJunctions(); diff --git a/eeschema/sch_eagle_plugin.cpp b/eeschema/sch_eagle_plugin.cpp index c6dc2166a8..bc9a74a0a9 100644 --- a/eeschema/sch_eagle_plugin.cpp +++ b/eeschema/sch_eagle_plugin.cpp @@ -25,7 +25,6 @@ #include #include -#include #include #include @@ -425,24 +424,6 @@ SCH_SHEET* SCH_EAGLE_PLUGIN::Load( const wxString& aFileName, KIWAY* aKiway, m_pi->SaveLibrary( getLibFileName().GetFullPath() ); - // Eagle sheets do not use a worksheet frame by default - WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance(); - pglayout.SetEmptyLayout(); - - wxFileName layoutfn( m_kiway->Prj().GetProjectPath(), "empty.kicad_wks" ); - wxFile layoutfile; - - if( layoutfile.Create( layoutfn.GetFullPath() ) ) - { - layoutfile.Write( WORKSHEET_LAYOUT::EmptyLayout() ); - layoutfile.Close(); - } - - BASE_SCREEN::m_PageLayoutDescrFileName = "empty.kicad_wks"; - - SCH_EDIT_FRAME* editor = (SCH_EDIT_FRAME*) m_kiway->Player( FRAME_SCH, true ); - editor->SaveProjectSettings( false ); - return m_rootSheet; }