Eagle import: fix memory leak on schematic sheets import
This commit is contained in:
parent
419a16ae58
commit
260f680c6c
|
@ -50,6 +50,7 @@
|
|||
#include <sch_eagle_plugin.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <dialog_symbol_remap.h>
|
||||
#include <worksheet_shape_builder.h>
|
||||
|
||||
|
||||
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,6 +815,7 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
|
|||
GetScreen()->SetModify();
|
||||
|
||||
UpdateFileHistory( fullFileName );
|
||||
SCH_SCREENS schematic;
|
||||
schematic.UpdateSymbolLinks(); // Update all symbol library links for all sheets.
|
||||
|
||||
// Ensure the schematic is fully segmented on first display
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
#include <wx/filename.h>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <sch_junction.h>
|
||||
#include <sch_sheet.h>
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue