From 108cf23892d7841b8e0c2739ec97a3240c8202ed Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 10 May 2020 18:02:58 -0400 Subject: [PATCH] Restore separate libedit settings for common settings params Be careful when calling config() in eeschema/libedit/pcbnew/modedit It's usually not the thing you want. A better fix for #4389 --- common/eda_draw_frame.cpp | 5 ++-- eeschema/eeschema_config.cpp | 8 +++++-- eeschema/libedit/lib_edit_frame.cpp | 37 ++++++++++------------------- eeschema/libedit/lib_edit_frame.h | 2 -- eeschema/sch_edit_frame.cpp | 2 +- 5 files changed, 21 insertions(+), 33 deletions(-) diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index da6bab0560..8f6ff40d9c 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -465,9 +465,8 @@ void EDA_DRAW_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) { EDA_BASE_FRAME::LoadSettings( aCfg ); - wxString baseCfgName = ConfigBaseName(); - COMMON_SETTINGS* cmnCfg = Pgm().GetCommonSettings(); - WINDOW_SETTINGS* window = GetWindowSettings( aCfg ); + COMMON_SETTINGS* cmnCfg = Pgm().GetCommonSettings(); + WINDOW_SETTINGS* window = GetWindowSettings( aCfg ); // Read units used in dialogs and toolbars SetUserUnits( static_cast( aCfg->m_System.units ) ); diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index bf51d2c12d..afe19af5ba 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -445,7 +445,9 @@ void SCH_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) void SCH_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) { - EDA_DRAW_FRAME::LoadSettings( config() ); + wxCHECK_RET( aCfg, "Call to SCH_BASE_FRAME::SaveSettings with null settings" ); + + EDA_DRAW_FRAME::LoadSettings( aCfg ); if( eeconfig() ) { @@ -471,7 +473,9 @@ void SCH_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) void SCH_BASE_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) { - EDA_DRAW_FRAME::SaveSettings( config() ); + wxCHECK_RET( aCfg, "Call to SCH_BASE_FRAME::SaveSettings with null settings" ); + + EDA_DRAW_FRAME::SaveSettings( aCfg ); if( eeconfig() ) { diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index 780405676f..d38396c204 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -210,14 +210,13 @@ LIB_EDIT_FRAME::~LIB_EDIT_FRAME() void LIB_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) { - SCH_BASE_FRAME::LoadSettings( eeconfig() ); + wxCHECK_RET( m_settings, "Call to LIB_EDIT_FRAME::LoadSettings with null m_settings" ); - if( m_settings ) - { - SetDefaultLineWidth( Mils2iu( m_settings->m_Defaults.line_width ) ); - SetDefaultTextSize( Mils2iu( m_settings->m_Defaults.text_size ) ); - m_showPinElectricalTypeName = m_settings->m_ShowPinElectricalType; - } + SCH_BASE_FRAME::LoadSettings( GetSettings() ); + + SetDefaultLineWidth( Mils2iu( m_settings->m_Defaults.line_width ) ); + SetDefaultTextSize( Mils2iu( m_settings->m_Defaults.text_size ) ); + m_showPinElectricalTypeName = m_settings->m_ShowPinElectricalType; GetRenderSettings()->m_ShowPinsElectricalType = GetShowElectricalType(); @@ -228,9 +227,11 @@ void LIB_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) } -void LIB_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg) +void LIB_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) { - SCH_BASE_FRAME::SaveSettings( eeconfig() ); + wxCHECK_RET( m_settings, "Call to LIB_EDIT_FRAME::LoadSettings with null m_settings" ); + + SCH_BASE_FRAME::SaveSettings( GetSettings() ); m_settings->m_Defaults.line_width = Iu2Mils( GetDefaultLineWidth() ); m_settings->m_Defaults.text_size = Iu2Mils( GetDefaultTextSize() ); @@ -239,26 +240,12 @@ void LIB_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg) } -WINDOW_SETTINGS* LIB_EDIT_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg ) -{ - auto cfg = Pgm().GetSettingsManager().GetAppSettings(); - - wxCHECK_MSG( cfg, nullptr, "Could not load libedit settings" ); - - return &cfg->m_Window; -} - - COLOR_SETTINGS* LIB_EDIT_FRAME::GetColorSettings() { - auto cfg = Pgm().GetSettingsManager().GetAppSettings(); - - wxCHECK_MSG( cfg, nullptr, "Could not load libedit settings" ); - - if( cfg->m_UseEeschemaColorSettings ) + if( GetSettings()->m_UseEeschemaColorSettings ) return m_colorSettings; else - return Pgm().GetSettingsManager().GetColorSettings( cfg->m_ColorTheme ); + return Pgm().GetSettingsManager().GetColorSettings( GetSettings()->m_ColorTheme ); } diff --git a/eeschema/libedit/lib_edit_frame.h b/eeschema/libedit/lib_edit_frame.h index 07b8ad3ef4..7d9ef57a52 100644 --- a/eeschema/libedit/lib_edit_frame.h +++ b/eeschema/libedit/lib_edit_frame.h @@ -234,8 +234,6 @@ public: void LoadSettings( APP_SETTINGS_BASE* aCfg ) override; void SaveSettings( APP_SETTINGS_BASE* aCfg ) override; - WINDOW_SETTINGS* GetWindowSettings( APP_SETTINGS_BASE* aCfg ) override; - LIBEDIT_SETTINGS* GetSettings() { return m_settings; diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 9eaff6310f..2d45004930 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -239,7 +239,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ): // Initialize grid id to the default value (50 mils): m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000; - LoadSettings( config() ); + LoadSettings( eeconfig() ); CreateScreens();