Move saving preferences out of the destructor.

For other reasons we wrap the adapters in a wxDataObject, which has
delayed destruction semantics, but that means the settings stuff may
no longer be around when the d'tor executes.

Fixes https://gitlab.com/kicad/code/kicad/issues/12371
This commit is contained in:
Jeff Young 2022-11-14 19:59:33 +00:00
parent bc0a753238
commit 93c6d99a6d
6 changed files with 15 additions and 3 deletions

View File

@ -182,9 +182,6 @@ LIB_TREE::~LIB_TREE()
{
// Stop the timer during destruction early to avoid potential race conditions (that do happen)
m_debounceTimer->Stop();
// Save the column widths to the config file
m_adapter->SaveSettings();
}

View File

@ -199,6 +199,9 @@ PICKED_SYMBOL SCH_BASE_FRAME::PickSymbolFromLibTree( const SYMBOL_LIBRARY_FILTER
if( dlg.ShowModal() == wxID_CANCEL )
return PICKED_SYMBOL();
// Save any changes to column widths, etc.
modelAdapter->SaveSettings();
PICKED_SYMBOL sel;
LIB_ID id = dlg.GetSelectedLibId( &sel.Unit );

View File

@ -581,6 +581,9 @@ bool SYMBOL_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
if( !saveAllLibraries( true ) )
return false;
// Save symbol tree column widths
m_libMgr->GetAdapter()->SaveSettings();
return true;
}

View File

@ -1016,6 +1016,9 @@ void SYMBOL_VIEWER_FRAME::OnSelectSymbol( wxCommandEvent& aEvent )
if( dlg.ShowQuasiModal() == wxID_CANCEL )
return;
// Save any changes to column widths, etc.
modelAdapter->SaveSettings();
id = dlg.GetSelectedLibId( &unit );
if( !id.IsValid() )

View File

@ -735,6 +735,9 @@ bool FOOTPRINT_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
}
}
// Save footprint tree column widths
m_adapter->SaveSettings();
return PCB_BASE_EDIT_FRAME::canCloseWindow( aEvent );
}

View File

@ -271,6 +271,9 @@ FOOTPRINT* PCB_BASE_FRAME::SelectFootprintFromLibTree( LIB_ID aPreselect )
if( dialog.ShowQuasiModal() == wxID_CANCEL )
return nullptr;
// Save any changes to column widths, etc.
adapter->SaveSettings();
if( dialog.IsExternalBrowserSelected() )
{
// SelectFootprintFromLibBrowser() returns the "full" footprint name, i.e.