Make sure projects are cleaned up nicely when frames close
PROJECT objects will be deleted by SETTINGS_MANAGER::UnloadProject so we need to make sure that this is called at an early enough point in the closing process that anything needed by the PROJECT dtor is still around. Also fix an issue where the schematic worksheet was depending on the project existing after the schematic had been reset.
This commit is contained in:
parent
79e40cf765
commit
32a7d00256
|
@ -120,6 +120,8 @@ void SCH_DRAW_PANEL::DisplaySheet( const SCH_SCREEN *aScreen )
|
|||
|
||||
if( aScreen )
|
||||
GetView()->DisplaySheet( const_cast<SCH_SCREEN*>( aScreen ) );
|
||||
else
|
||||
GetView()->Cleanup();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -307,6 +307,10 @@ SCH_EDIT_FRAME::~SCH_EDIT_FRAME()
|
|||
SetScreen( NULL );
|
||||
|
||||
delete m_schematic;
|
||||
|
||||
// Close the project if we are standalone, so it gets cleaned up properly
|
||||
if( Kiface().IsSingle() )
|
||||
GetSettingsManager()->UnloadProject( &Prj() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -559,6 +563,9 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
|
|||
// all sub sheets are deleted, only the main sheet is usable
|
||||
GetCurrentSheet().clear();
|
||||
|
||||
// Clear view before destroying schematic as repaints depend on schematic being valid
|
||||
SetScreen( nullptr );
|
||||
|
||||
GetSettingsManager()->SaveProject();
|
||||
Schematic().SetTemplateFieldNames( nullptr );
|
||||
Schematic().Reset();
|
||||
|
|
|
@ -62,6 +62,13 @@ SCH_VIEW::~SCH_VIEW()
|
|||
{
|
||||
}
|
||||
|
||||
void SCH_VIEW::Cleanup()
|
||||
{
|
||||
Clear();
|
||||
m_worksheet.reset();
|
||||
m_preview.reset();
|
||||
}
|
||||
|
||||
|
||||
void SCH_VIEW::SetScale( double aScale, VECTOR2D aAnchor )
|
||||
{
|
||||
|
|
|
@ -77,6 +77,8 @@ public:
|
|||
SCH_VIEW( bool aIsDynamic, SCH_BASE_FRAME* aFrame );
|
||||
~SCH_VIEW();
|
||||
|
||||
void Cleanup();
|
||||
|
||||
void DisplaySheet( SCH_SHEET* aSheet );
|
||||
void DisplaySheet( SCH_SCREEN* aScreen );
|
||||
void DisplayComponent( LIB_PART* aPart );
|
||||
|
|
|
@ -328,6 +328,9 @@ void KICAD_MANAGER_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
|||
{
|
||||
Event.SetCanVeto( true );
|
||||
|
||||
// Ensure the project is closed before destruction.
|
||||
CloseProject( true );
|
||||
|
||||
m_leftWin->Show( false );
|
||||
|
||||
Destroy();
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <kiface_i.h>
|
||||
#include <pcb_base_edit_frame.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <pcb_layer_widget.h>
|
||||
|
@ -59,6 +60,10 @@ PCB_BASE_EDIT_FRAME::~PCB_BASE_EDIT_FRAME()
|
|||
GFootprintList.WriteCacheToFile( &footprintInfoCache );
|
||||
}
|
||||
|
||||
// Close the project if we are standalone, so it gets cleaned up properly
|
||||
if( Kiface().IsSingle() )
|
||||
GetSettingsManager()->UnloadProject( &Prj() );
|
||||
|
||||
GetCanvas()->GetView()->Clear();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue