Fix some things about template fieldname synchronization
This commit is contained in:
parent
96b91e65ea
commit
498fa8d8ba
|
@ -261,8 +261,6 @@ bool SCH_EDIT_FRAME::LoadProjectSettings()
|
|||
|
||||
pglayout.SetPageLayout( filename );
|
||||
|
||||
Prj().GetProjectFile().m_TemplateFieldNames = &m_templateFieldNames;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -276,18 +276,24 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
|||
// it knows what consequences that will have on other KIFACEs running and using
|
||||
// this same PROJECT. It can be very harmful if that calling code is stupid.
|
||||
|
||||
// NOTE: The calling code should never call this in hosted (non-standalone) mode with a
|
||||
// different project than what has been loaded by the manager frame. This will crash.
|
||||
|
||||
bool differentProject = pro.GetFullPath() != Prj().GetProjectFullName();
|
||||
|
||||
if( differentProject )
|
||||
{
|
||||
GetSettingsManager()->SaveProject();
|
||||
GetSettingsManager()->UnloadProject( &Prj() );
|
||||
GetSettingsManager()->LoadProject( pro.GetFullPath() );
|
||||
}
|
||||
|
||||
if( schFileType == SCH_IO_MGR::SCH_LEGACY )
|
||||
{
|
||||
// Don't reload the symbol libraries if we are just launching Eeschema from KiCad again.
|
||||
// They are already saved in the kiface project object.
|
||||
if( pro.GetFullPath() != Prj().GetProjectFullName()
|
||||
|| !Prj().GetElem( PROJECT::ELEM_SCH_PART_LIBS ) )
|
||||
if( differentProject || !Prj().GetElem( PROJECT::ELEM_SCH_PART_LIBS ) )
|
||||
{
|
||||
GetSettingsManager()->SaveProject();
|
||||
GetSettingsManager()->UnloadProject( &Prj() );
|
||||
|
||||
GetSettingsManager()->LoadProject( pro.GetFullPath() );
|
||||
|
||||
// load the libraries here, not in SCH_SCREEN::Draw() which is a context
|
||||
// that will not tolerate DisplayError() dialog since we're already in an
|
||||
// event handler in there.
|
||||
|
@ -303,10 +309,6 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
|||
Prj().SetElem( PROJECT::ELEM_SCH_PART_LIBS, NULL );
|
||||
}
|
||||
|
||||
// Make sure the project file name is set (it won't be in standalone mode)
|
||||
if( pro.GetFullPath() != Prj().GetProjectFullName() )
|
||||
GetSettingsManager()->LoadProject( pro.GetFullPath() );
|
||||
|
||||
// Load the symbol library table, this will be used forever more.
|
||||
Prj().SetElem( PROJECT::ELEM_SYMBOL_LIB_TABLE, NULL );
|
||||
Prj().SchSymbolLibTable();
|
||||
|
|
|
@ -213,8 +213,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
|
|||
{
|
||||
m_schematic = new SCHEMATIC( nullptr );
|
||||
|
||||
Prj().GetProjectFile().m_TemplateFieldNames = &m_templateFieldNames;
|
||||
|
||||
m_showBorderAndTitleBlock = true; // true to show sheet references
|
||||
m_hasAutoSave = true;
|
||||
m_AboutTitle = "Eeschema";
|
||||
|
@ -303,7 +301,8 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
|
|||
SCH_EDIT_FRAME::~SCH_EDIT_FRAME()
|
||||
{
|
||||
GetSettingsManager()->SaveProject();
|
||||
Prj().GetProjectFile().m_TemplateFieldNames = nullptr;
|
||||
Schematic().SetTemplateFieldNames( nullptr );
|
||||
Schematic().Reset();
|
||||
|
||||
// Shutdown all running tools
|
||||
if( m_toolManager )
|
||||
|
@ -424,6 +423,8 @@ void SCH_EDIT_FRAME::CreateScreens()
|
|||
{
|
||||
m_schematic->Reset();
|
||||
m_schematic->SetProject( &Prj() );
|
||||
m_schematic->SetTemplateFieldNames( &m_templateFieldNames );
|
||||
|
||||
m_schematic->SetRoot( new SCH_SHEET( m_schematic ) );
|
||||
|
||||
m_defaults = &m_schematic->Settings();
|
||||
|
|
|
@ -85,6 +85,18 @@ void SCHEMATIC::SetProject( PROJECT* aPrj )
|
|||
}
|
||||
|
||||
|
||||
void SCHEMATIC::SetTemplateFieldNames( TEMPLATES* aTemplates )
|
||||
{
|
||||
wxASSERT( m_project );
|
||||
PROJECT_FILE& project = m_project->GetProjectFile();
|
||||
|
||||
project.m_TemplateFieldNames = aTemplates;
|
||||
|
||||
if( project.m_SchematicSettings )
|
||||
project.m_SchematicSettings->m_TemplateFieldNames = aTemplates;
|
||||
}
|
||||
|
||||
|
||||
void SCHEMATIC::SetRoot( SCH_SHEET* aRootSheet )
|
||||
{
|
||||
wxCHECK_RET( aRootSheet, "Call to SetRoot with null SCH_SHEET!" );
|
||||
|
|
|
@ -81,6 +81,9 @@ public:
|
|||
|
||||
void SetProject( PROJECT* aPrj );
|
||||
|
||||
/// Sets up the template fieldnames link if this project is opened in eeschema
|
||||
void SetTemplateFieldNames( TEMPLATES* aTemplates );
|
||||
|
||||
/**
|
||||
* Builds and returns an updated schematic hierarchy
|
||||
* TODO: can this be cached?
|
||||
|
|
Loading…
Reference in New Issue