Commit c63fa6ff authored by Dick Hollenbeck's avatar Dick Hollenbeck

Add EDA_BASE_FRAME::Show() and call SaveSettings() only from there for all...

Add EDA_BASE_FRAME::Show() and call SaveSettings() only from there for all derived wxFrames.  Remove calls to SaveSettings() elsewhere.
parent 786bb81c
...@@ -141,8 +141,6 @@ void EDA_3D_FRAME::Exit3DFrame( wxCommandEvent& event ) ...@@ -141,8 +141,6 @@ void EDA_3D_FRAME::Exit3DFrame( wxCommandEvent& event )
void EDA_3D_FRAME::OnCloseWindow( wxCloseEvent& Event ) void EDA_3D_FRAME::OnCloseWindow( wxCloseEvent& Event )
{ {
SaveSettings();
if( Parent() ) if( Parent() )
Parent()->m_Draw3DFrame = NULL; Parent()->m_Draw3DFrame = NULL;
......
...@@ -51,13 +51,13 @@ ...@@ -51,13 +51,13 @@
#define DEFAULT_AUTO_SAVE_INTERVAL 600 #define DEFAULT_AUTO_SAVE_INTERVAL 600
const wxChar* traceAutoSave = wxT( "KicadAutoSave" ); const wxChar traceAutoSave[] = wxT( "KicadAutoSave" );
/// Configuration file entry name for auto save interval. /// Configuration file entry name for auto save interval.
static const wxChar* entryAutoSaveInterval = wxT( "AutoSaveInterval" ); static const wxChar entryAutoSaveInterval[] = wxT( "AutoSaveInterval" );
/// Configuration file entry for wxAuiManger perspective. /// Configuration file entry for wxAuiManger perspective.
static const wxChar* entryPerspective = wxT( "Perspective" ); static const wxChar entryPerspective[] = wxT( "Perspective" );
...@@ -141,6 +141,19 @@ bool EDA_BASE_FRAME::ProcessEvent( wxEvent& aEvent ) ...@@ -141,6 +141,19 @@ bool EDA_BASE_FRAME::ProcessEvent( wxEvent& aEvent )
} }
bool EDA_BASE_FRAME::Show( bool show )
{
if( !show ) // closing
{
SaveSettings(); // virtual, wxFrame specific
}
int ret = wxFrame::Show( show );
return ret;
}
void EDA_BASE_FRAME::onAutoSaveTimer( wxTimerEvent& aEvent ) void EDA_BASE_FRAME::onAutoSaveTimer( wxTimerEvent& aEvent )
{ {
if( !doAutoSave() ) if( !doAutoSave() )
...@@ -231,7 +244,7 @@ void EDA_BASE_FRAME::SaveSettings() ...@@ -231,7 +244,7 @@ void EDA_BASE_FRAME::SaveSettings()
wxString text; wxString text;
wxConfig* config = wxGetApp().GetSettings(); wxConfig* config = wxGetApp().GetSettings();
if( ( config == NULL ) || IsIconized() ) if( !config || IsIconized() )
return; return;
m_FrameSize = GetSize(); m_FrameSize = GetSize();
...@@ -258,10 +271,15 @@ void EDA_BASE_FRAME::SaveSettings() ...@@ -258,10 +271,15 @@ void EDA_BASE_FRAME::SaveSettings()
config->Write( text, m_autoSaveInterval ); config->Write( text, m_autoSaveInterval );
} }
// Once this is fully implemented, wxAuiManager will be used to maintain the persistance of // Once this is fully implemented, wxAuiManager will be used to maintain
// the main frame and all it's managed windows and all of the legacy frame persistence // the persistance of the main frame and all it's managed windows and
// position code can be removed. // all of the legacy frame persistence position code can be removed.
config->Write( m_FrameName + entryPerspective, m_auimgr.SavePerspective() ); wxString perspective = m_auimgr.SavePerspective();
// printf( "perspective(%s): %s\n",
// TO_UTF8( m_FrameName + entryPerspective ), TO_UTF8( perspective ) );
config->Write( m_FrameName + entryPerspective, perspective );
} }
...@@ -270,6 +288,7 @@ void EDA_BASE_FRAME::PrintMsg( const wxString& text ) ...@@ -270,6 +288,7 @@ void EDA_BASE_FRAME::PrintMsg( const wxString& text )
SetStatusText( text ); SetStatusText( text );
} }
void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName, void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName,
wxFileHistory * aFileHistory ) wxFileHistory * aFileHistory )
{ {
...@@ -283,7 +302,7 @@ void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName, ...@@ -283,7 +302,7 @@ void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName,
wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type, wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type,
wxFileHistory * aFileHistory ) wxFileHistory* aFileHistory )
{ {
wxString fn, msg; wxString fn, msg;
size_t i; size_t i;
......
...@@ -158,7 +158,6 @@ void DISPLAY_FOOTPRINTS_FRAME::OnCloseWindow( wxCloseEvent& event ) ...@@ -158,7 +158,6 @@ void DISPLAY_FOOTPRINTS_FRAME::OnCloseWindow( wxCloseEvent& event )
if( m_Draw3DFrame ) if( m_Draw3DFrame )
m_Draw3DFrame->Close( true ); m_Draw3DFrame->Close( true );
SaveSettings();
Destroy(); Destroy();
} }
......
...@@ -337,7 +337,6 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event ) ...@@ -337,7 +337,6 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
m_DisplayFootprintFrame->Close( true ); m_DisplayFootprintFrame->Close( true );
m_modified = false; m_modified = false;
SaveSettings();
Destroy(); Destroy();
return; return;
} }
......
...@@ -375,7 +375,6 @@ void LIB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) ...@@ -375,7 +375,6 @@ void LIB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
} }
} }
SaveSettings();
Destroy(); Destroy();
} }
......
...@@ -505,7 +505,6 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent ) ...@@ -505,7 +505,6 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
/* all sub sheets are deleted, only the main sheet is usable */ /* all sub sheets are deleted, only the main sheet is usable */
m_CurrentSheet->Clear(); m_CurrentSheet->Clear();
SaveSettings();
Destroy(); Destroy();
} }
......
...@@ -250,8 +250,6 @@ LIB_VIEW_FRAME* LIB_VIEW_FRAME::GetActiveLibraryViewer() ...@@ -250,8 +250,6 @@ LIB_VIEW_FRAME* LIB_VIEW_FRAME::GetActiveLibraryViewer()
void LIB_VIEW_FRAME::OnCloseWindow( wxCloseEvent& Event ) void LIB_VIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
{ {
SaveSettings();
if( m_semaphore ) if( m_semaphore )
{ {
m_semaphore->Post(); m_semaphore->Post();
......
...@@ -177,7 +177,6 @@ GERBVIEW_FRAME::~GERBVIEW_FRAME() ...@@ -177,7 +177,6 @@ GERBVIEW_FRAME::~GERBVIEW_FRAME()
void GERBVIEW_FRAME::OnCloseWindow( wxCloseEvent& Event ) void GERBVIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
{ {
SaveSettings();
Destroy(); Destroy();
} }
......
...@@ -101,7 +101,7 @@ enum ID_DRAWFRAME_TYPE ...@@ -101,7 +101,7 @@ enum ID_DRAWFRAME_TYPE
/// Custom trace mask to enable and disable auto save tracing. /// Custom trace mask to enable and disable auto save tracing.
extern const wxChar* traceAutoSave; extern const wxChar traceAutoSave[];
/** /**
...@@ -175,7 +175,18 @@ public: ...@@ -175,7 +175,18 @@ public:
* @warning If you override this function in a derived class, make sure you call * @warning If you override this function in a derived class, make sure you call
* down to this or the auto save feature will be disabled. * down to this or the auto save feature will be disabled.
*/ */
virtual bool ProcessEvent( wxEvent& aEvent ); bool ProcessEvent( wxEvent& aEvent ); // overload wxFrame::ProcessEvent()
/**
* Function Show
* hooks the wxFrame close scenario so we can grab the window size and position
* in the wxFrame specific SaveSettings() function. SaveSettings() is
* called for all derived wxFrames in this base class overload. Calling it
* from a destructor is deprecated since the wxFrame's position is not available
* in the destructor on linux. In other words, don't call SaveSettings() anywhere,
* except in this one function.
*/
bool Show( bool show ); // overload wxFrame::Show()
void SetAutoSaveInterval( int aInterval ) { m_autoSaveInterval = aInterval; } void SetAutoSaveInterval( int aInterval ) { m_autoSaveInterval = aInterval; }
...@@ -216,11 +227,13 @@ public: ...@@ -216,11 +227,13 @@ public:
virtual void LoadSettings(); virtual void LoadSettings();
/** /**
* Save common frame parameters from configuration. * Save common frame parameters to configuration data file.
* *
* The method is virtual so you can override it to save frame specific * The method is virtual so you can override it to save frame specific
* parameters. Don't forget to call the base method or your frames won't * parameters. Don't forget to call the base class's SaveSettings() from
* remember their positions and sizes. * your derived SaveSettings() otherwise the frames won't remember their
* positions and sizes. The virtual call to SaveSettings is done safely
* only in EDA_BASE_FRAME::Show( bool ).
*/ */
virtual void SaveSettings(); virtual void SaveSettings();
......
...@@ -164,8 +164,6 @@ void KICAD_MANAGER_FRAME::OnCloseWindow( wxCloseEvent& Event ) ...@@ -164,8 +164,6 @@ void KICAD_MANAGER_FRAME::OnCloseWindow( wxCloseEvent& Event )
Event.SetCanVeto( true ); Event.SetCanVeto( true );
SaveSettings();
// Close the help frame // Close the help frame
if( wxGetApp().GetHtmlHelpController() ) if( wxGetApp().GetHtmlHelpController() )
{ {
......
...@@ -194,6 +194,7 @@ void PL_EDITOR_FRAME::OnCloseWindow( wxCloseEvent& Event ) ...@@ -194,6 +194,7 @@ void PL_EDITOR_FRAME::OnCloseWindow( wxCloseEvent& Event )
GetChars( filename ) ); GetChars( filename ) );
int ii = DisplayExitDialog( this, msg ); int ii = DisplayExitDialog( this, msg );
switch( ii ) switch( ii )
{ {
case wxID_CANCEL: case wxID_CANCEL:
...@@ -228,12 +229,11 @@ void PL_EDITOR_FRAME::OnCloseWindow( wxCloseEvent& Event ) ...@@ -228,12 +229,11 @@ void PL_EDITOR_FRAME::OnCloseWindow( wxCloseEvent& Event )
} }
} }
SaveSettings();
wxGetApp().SaveCurrentSetupValues( m_configSettings );
// do not show the window because we do not want any paint event // do not show the window because we do not want any paint event
Show( false ); Show( false );
wxGetApp().SaveCurrentSetupValues( m_configSettings );
// On Linux, m_propertiesPagelayout must be destroyed // On Linux, m_propertiesPagelayout must be destroyed
// before deleting the main frame to avoid a crash when closing // before deleting the main frame to avoid a crash when closing
m_propertiesPagelayout->Destroy(); m_propertiesPagelayout->Destroy();
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
*/ */
/* functions relatives to the design rules editor /* functions relative to the design rules editor
*/ */
#include <fctsys.h> #include <fctsys.h>
#include <class_drawpanel.h> #include <class_drawpanel.h>
...@@ -46,10 +46,9 @@ ...@@ -46,10 +46,9 @@
#include <wx/generic/gridctrl.h> #include <wx/generic/gridctrl.h>
#include <dialog_design_rules_aux_helper_class.h> #include <dialog_design_rules_aux_helper_class.h>
// Column labels for net lists // Column labels for net lists
#define NET_TITLE _( "Net" ) #define NET_TITLE _( "Net" )
#define CLASS_TITLE _( "Class" ) #define CLASS_TITLE _( "Class" )
// Field Positions on rules grid // Field Positions on rules grid
enum { enum {
......
...@@ -304,8 +304,6 @@ FOOTPRINT_WIZARD_FRAME::~FOOTPRINT_WIZARD_FRAME() ...@@ -304,8 +304,6 @@ FOOTPRINT_WIZARD_FRAME::~FOOTPRINT_WIZARD_FRAME()
*/ */
void FOOTPRINT_WIZARD_FRAME::OnCloseWindow( wxCloseEvent& Event ) void FOOTPRINT_WIZARD_FRAME::OnCloseWindow( wxCloseEvent& Event )
{ {
SaveSettings();
if( m_Semaphore ) if( m_Semaphore )
{ {
m_Semaphore->Post(); m_Semaphore->Post();
......
...@@ -29,7 +29,7 @@ While exploring the possibility of local caching of the zip file, I discovered ...@@ -29,7 +29,7 @@ While exploring the possibility of local caching of the zip file, I discovered
this command to retrieve the time stamp of the last commit into any particular this command to retrieve the time stamp of the last commit into any particular
repo: repo:
$time curl -I -i https://api.github.com/repos/KiCad/Mounting_Holes.pretty $time curl -I -i https://api.github.com/repos/KiCad/Mounting_Holes.pretty/commits
This gets just the header to what would otherwise return information on the repo This gets just the header to what would otherwise return information on the repo
in JSON format, and is reasonably faster than actually getting the repo in JSON format, and is reasonably faster than actually getting the repo
......
...@@ -384,7 +384,6 @@ void FOOTPRINT_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) ...@@ -384,7 +384,6 @@ void FOOTPRINT_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
} }
//close the editor //close the editor
SaveSettings();
Destroy(); Destroy();
} }
......
...@@ -163,10 +163,13 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* aParent, ...@@ -163,10 +163,13 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* aParent,
// Ensure all layers and items are visible: // Ensure all layers and items are visible:
GetBoard()->SetVisibleAlls(); GetBoard()->SetVisibleAlls();
SetScreen( new PCB_SCREEN( GetPageSizeIU() ) ); SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
GetScreen()->m_Center = true; // Center coordinate origins on screen. GetScreen()->m_Center = true; // Center coordinate origins on screen.
LoadSettings(); LoadSettings();
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
ReCreateHToolbar(); ReCreateHToolbar();
...@@ -239,9 +242,12 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* aParent, ...@@ -239,9 +242,12 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* aParent,
m_auimgr.GetPane( m_mainToolBar ).BestSize( tbsize ); m_auimgr.GetPane( m_mainToolBar ).BestSize( tbsize );
} }
// Set min size (overwrite params read in LoadPerspective(), is any) #if 0 // no.
// Set min size (overwrite params read in LoadPerspective(), if any)
m_auimgr.GetPane( m_libList ).MinSize( minsize ); m_auimgr.GetPane( m_libList ).MinSize( minsize );
m_auimgr.GetPane( m_footprintList ).MinSize( minsize ); m_auimgr.GetPane( m_footprintList ).MinSize( minsize );
#endif
// after changing something to the aui manager, // after changing something to the aui manager,
// call Update()() to reflect the changes // call Update()() to reflect the changes
...@@ -260,8 +266,6 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* aParent, ...@@ -260,8 +266,6 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* aParent,
FOOTPRINT_VIEWER_FRAME::~FOOTPRINT_VIEWER_FRAME() FOOTPRINT_VIEWER_FRAME::~FOOTPRINT_VIEWER_FRAME()
{ {
SaveSettings();
if( m_Draw3DFrame ) if( m_Draw3DFrame )
m_Draw3DFrame->Destroy(); m_Draw3DFrame->Destroy();
} }
......
...@@ -708,8 +708,6 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) ...@@ -708,8 +708,6 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
wxMessageBox( msg, wxGetApp().GetAppName(), wxOK | wxICON_ERROR, this ); wxMessageBox( msg, wxGetApp().GetAppName(), wxOK | wxICON_ERROR, this );
} }
SaveSettings();
// Delete board structs and undo/redo lists, to avoid crash on exit // Delete board structs and undo/redo lists, to avoid crash on exit
// when deleting some structs (mainly in undo/redo lists) too late // when deleting some structs (mainly in undo/redo lists) too late
Clear_Pcb( false ); Clear_Pcb( false );
...@@ -717,6 +715,7 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) ...@@ -717,6 +715,7 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
// do not show the window because ScreenPcb will be deleted and we do not // do not show the window because ScreenPcb will be deleted and we do not
// want any paint event // want any paint event
Show( false ); Show( false );
Destroy(); Destroy();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment