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 )
void EDA_3D_FRAME::OnCloseWindow( wxCloseEvent& Event )
{
SaveSettings();
if( Parent() )
Parent()->m_Draw3DFrame = NULL;
......
......@@ -51,13 +51,13 @@
#define DEFAULT_AUTO_SAVE_INTERVAL 600
const wxChar* traceAutoSave = wxT( "KicadAutoSave" );
const wxChar traceAutoSave[] = wxT( "KicadAutoSave" );
/// 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.
static const wxChar* entryPerspective = wxT( "Perspective" );
static const wxChar entryPerspective[] = wxT( "Perspective" );
......@@ -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 )
{
if( !doAutoSave() )
......@@ -231,7 +244,7 @@ void EDA_BASE_FRAME::SaveSettings()
wxString text;
wxConfig* config = wxGetApp().GetSettings();
if( ( config == NULL ) || IsIconized() )
if( !config || IsIconized() )
return;
m_FrameSize = GetSize();
......@@ -258,10 +271,15 @@ void EDA_BASE_FRAME::SaveSettings()
config->Write( text, m_autoSaveInterval );
}
// Once this is fully implemented, wxAuiManager will be used to maintain the persistance of
// the main frame and all it's managed windows and all of the legacy frame persistence
// position code can be removed.
config->Write( m_FrameName + entryPerspective, m_auimgr.SavePerspective() );
// Once this is fully implemented, wxAuiManager will be used to maintain
// the persistance of the main frame and all it's managed windows and
// all of the legacy frame persistence position code can be removed.
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 )
SetStatusText( text );
}
void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName,
wxFileHistory * aFileHistory )
{
......@@ -283,7 +302,7 @@ void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName,
wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type,
wxFileHistory * aFileHistory )
wxFileHistory* aFileHistory )
{
wxString fn, msg;
size_t i;
......
......@@ -158,7 +158,6 @@ void DISPLAY_FOOTPRINTS_FRAME::OnCloseWindow( wxCloseEvent& event )
if( m_Draw3DFrame )
m_Draw3DFrame->Close( true );
SaveSettings();
Destroy();
}
......
......@@ -337,7 +337,6 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
m_DisplayFootprintFrame->Close( true );
m_modified = false;
SaveSettings();
Destroy();
return;
}
......
......@@ -375,7 +375,6 @@ void LIB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
}
}
SaveSettings();
Destroy();
}
......
......@@ -505,7 +505,6 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
/* all sub sheets are deleted, only the main sheet is usable */
m_CurrentSheet->Clear();
SaveSettings();
Destroy();
}
......
......@@ -250,8 +250,6 @@ LIB_VIEW_FRAME* LIB_VIEW_FRAME::GetActiveLibraryViewer()
void LIB_VIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
{
SaveSettings();
if( m_semaphore )
{
m_semaphore->Post();
......
......@@ -177,7 +177,6 @@ GERBVIEW_FRAME::~GERBVIEW_FRAME()
void GERBVIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
{
SaveSettings();
Destroy();
}
......
......@@ -101,7 +101,7 @@ enum ID_DRAWFRAME_TYPE
/// Custom trace mask to enable and disable auto save tracing.
extern const wxChar* traceAutoSave;
extern const wxChar traceAutoSave[];
/**
......@@ -175,7 +175,18 @@ public:
* @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.
*/
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; }
......@@ -216,11 +227,13 @@ public:
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
* parameters. Don't forget to call the base method or your frames won't
* remember their positions and sizes.
* parameters. Don't forget to call the base class's SaveSettings() from
* 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();
......
......@@ -164,8 +164,6 @@ void KICAD_MANAGER_FRAME::OnCloseWindow( wxCloseEvent& Event )
Event.SetCanVeto( true );
SaveSettings();
// Close the help frame
if( wxGetApp().GetHtmlHelpController() )
{
......
......@@ -194,6 +194,7 @@ void PL_EDITOR_FRAME::OnCloseWindow( wxCloseEvent& Event )
GetChars( filename ) );
int ii = DisplayExitDialog( this, msg );
switch( ii )
{
case wxID_CANCEL:
......@@ -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
Show( false );
wxGetApp().SaveCurrentSetupValues( m_configSettings );
// On Linux, m_propertiesPagelayout must be destroyed
// before deleting the main frame to avoid a crash when closing
m_propertiesPagelayout->Destroy();
......
......@@ -28,7 +28,7 @@
*/
/* functions relatives to the design rules editor
/* functions relative to the design rules editor
*/
#include <fctsys.h>
#include <class_drawpanel.h>
......@@ -46,10 +46,9 @@
#include <wx/generic/gridctrl.h>
#include <dialog_design_rules_aux_helper_class.h>
// Column labels for net lists
#define NET_TITLE _( "Net" )
#define CLASS_TITLE _( "Class" )
#define NET_TITLE _( "Net" )
#define CLASS_TITLE _( "Class" )
// Field Positions on rules grid
enum {
......
......@@ -304,8 +304,6 @@ FOOTPRINT_WIZARD_FRAME::~FOOTPRINT_WIZARD_FRAME()
*/
void FOOTPRINT_WIZARD_FRAME::OnCloseWindow( wxCloseEvent& Event )
{
SaveSettings();
if( m_Semaphore )
{
m_Semaphore->Post();
......
......@@ -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
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
in JSON format, and is reasonably faster than actually getting the repo
......
......@@ -384,7 +384,6 @@ void FOOTPRINT_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
}
//close the editor
SaveSettings();
Destroy();
}
......
......@@ -163,10 +163,13 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* aParent,
// Ensure all layers and items are visible:
GetBoard()->SetVisibleAlls();
SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
GetScreen()->m_Center = true; // Center coordinate origins on screen.
LoadSettings();
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
ReCreateHToolbar();
......@@ -239,9 +242,12 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* aParent,
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_footprintList ).MinSize( minsize );
#endif
// after changing something to the aui manager,
// call Update()() to reflect the changes
......@@ -260,8 +266,6 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* aParent,
FOOTPRINT_VIEWER_FRAME::~FOOTPRINT_VIEWER_FRAME()
{
SaveSettings();
if( m_Draw3DFrame )
m_Draw3DFrame->Destroy();
}
......
......@@ -708,8 +708,6 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
wxMessageBox( msg, wxGetApp().GetAppName(), wxOK | wxICON_ERROR, this );
}
SaveSettings();
// Delete board structs and undo/redo lists, to avoid crash on exit
// when deleting some structs (mainly in undo/redo lists) too late
Clear_Pcb( false );
......@@ -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
// want any paint event
Show( false );
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