Fix a few issues with Close Project
A new empty project needs to be reopened for now Footprint info cache write only works with a project for now
This commit is contained in:
parent
c992570427
commit
43ab43ec9e
|
@ -742,6 +742,12 @@ PROJECT& SETTINGS_MANAGER::Prj() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SETTINGS_MANAGER::IsProjectOpen() const
|
||||||
|
{
|
||||||
|
return !m_projects.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PROJECT* SETTINGS_MANAGER::GetProject( const wxString& aFullPath ) const
|
PROJECT* SETTINGS_MANAGER::GetProject( const wxString& aFullPath ) const
|
||||||
{
|
{
|
||||||
if( m_projects.count( aFullPath ) )
|
if( m_projects.count( aFullPath ) )
|
||||||
|
|
|
@ -200,6 +200,13 @@ public:
|
||||||
*/
|
*/
|
||||||
bool UnloadProject( PROJECT* aProject, bool aSave = true );
|
bool UnloadProject( PROJECT* aProject, bool aSave = true );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper for checking if we have a project open
|
||||||
|
* TODO: This should be deprecated along with Prj() once we support multiple projects fully
|
||||||
|
* @return true if a call to Prj() will succeed
|
||||||
|
*/
|
||||||
|
bool IsProjectOpen() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A helper while we are not MDI-capable -- return the one and only project
|
* A helper while we are not MDI-capable -- return the one and only project
|
||||||
* @return the loaded project
|
* @return the loaded project
|
||||||
|
|
|
@ -369,6 +369,10 @@ bool KICAD_MANAGER_FRAME::CloseProject( bool aSave )
|
||||||
|
|
||||||
m_active_project = false;
|
m_active_project = false;
|
||||||
mgr.UnloadProject( &Prj() );
|
mgr.UnloadProject( &Prj() );
|
||||||
|
|
||||||
|
// TODO(JE): Remove this if apps are refactored to not assume Prj() always works
|
||||||
|
// Need to create a project early for now (it can have an empty path for the moment)
|
||||||
|
mgr.LoadProject( "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearMsg();
|
ClearMsg();
|
||||||
|
|
|
@ -52,19 +52,26 @@ PCB_BASE_EDIT_FRAME::PCB_BASE_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PCB_BASE_EDIT_FRAME::~PCB_BASE_EDIT_FRAME()
|
PCB_BASE_EDIT_FRAME::~PCB_BASE_EDIT_FRAME()
|
||||||
{
|
{
|
||||||
if( wxFileName::IsDirWritable( Prj().GetProjectPath() ) )
|
GetCanvas()->GetView()->Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_BASE_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
|
||||||
|
{
|
||||||
|
SETTINGS_MANAGER* mgr = GetSettingsManager();
|
||||||
|
|
||||||
|
if( mgr->IsProjectOpen() && wxFileName::IsDirWritable( Prj().GetProjectPath() ) )
|
||||||
{
|
{
|
||||||
wxTextFile footprintInfoCache( Prj().GetProjectPath() + "fp-info-cache" );
|
wxTextFile footprintInfoCache( Prj().GetProjectPath() + "fp-info-cache" );
|
||||||
GFootprintList.WriteCacheToFile( &footprintInfoCache );
|
GFootprintList.WriteCacheToFile( &footprintInfoCache );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the project if we are standalone, so it gets cleaned up properly
|
// Close the project if we are standalone, so it gets cleaned up properly
|
||||||
if( Kiface().IsSingle() )
|
if( mgr->IsProjectOpen() && Kiface().IsSingle() )
|
||||||
GetSettingsManager()->UnloadProject( &Prj() );
|
mgr->UnloadProject( &Prj() );
|
||||||
|
|
||||||
GetCanvas()->GetView()->Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,8 @@ public:
|
||||||
|
|
||||||
virtual ~PCB_BASE_EDIT_FRAME();
|
virtual ~PCB_BASE_EDIT_FRAME();
|
||||||
|
|
||||||
|
void OnCloseWindow( wxCloseEvent& aEvent ) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If a library name is given, creates a new footprint library in the project folder
|
* If a library name is given, creates a new footprint library in the project folder
|
||||||
* with the given name. If no library name is given it prompts user for a library path,
|
* with the given name. If no library name is given it prompts user for a library path,
|
||||||
|
|
|
@ -633,6 +633,8 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
|
||||||
// want any paint event
|
// want any paint event
|
||||||
Show( false );
|
Show( false );
|
||||||
|
|
||||||
|
PCB_BASE_EDIT_FRAME::OnCloseWindow( aEvent );
|
||||||
|
|
||||||
// Close frame:
|
// Close frame:
|
||||||
aEvent.Skip();
|
aEvent.Skip();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue