From 7584ccc758a3bf31e65e04766591db8ebdcf541e Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 26 Sep 2022 18:54:42 +0200 Subject: [PATCH] Fix duplicate variable member m_userUnits, creating issues depending on the way it was acceded (by name or by accessor). --- common/eda_draw_frame.cpp | 11 ++++++----- eeschema/eeschema_config.cpp | 3 +-- eeschema/sim/sim_plot_frame.cpp | 2 +- include/eda_base_frame.h | 3 +-- pagelayout_editor/pl_editor_frame.cpp | 8 ++++---- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index 6d1da23c6c..6fe65a1df2 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2004-2017 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2008 Wayne Stambaugh - * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -106,10 +106,11 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame // BLACK for Pcbnew, BLACK or WHITE for Eeschema m_colorSettings = nullptr; m_msgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight( this ); - m_userUnits = EDA_UNITS::MILLIMETRES; m_polarCoords = false; m_findReplaceData = std::make_unique(); + SetUserUnits( EDA_UNITS::MILLIMETRES ); + m_auimgr.SetFlags( wxAUI_MGR_DEFAULT ); CreateStatusBar( 8 ); @@ -273,7 +274,7 @@ void EDA_DRAW_FRAME::ToggleUserUnits() } else { - SetUserUnits( m_userUnits == EDA_UNITS::INCHES ? EDA_UNITS::MILLIMETRES + SetUserUnits( GetUserUnits() == EDA_UNITS::INCHES ? EDA_UNITS::MILLIMETRES : EDA_UNITS::INCHES ); unitsChangeRefresh(); @@ -588,7 +589,7 @@ void EDA_DRAW_FRAME::DisplayUnitsMsg() { wxString msg; - switch( m_userUnits ) + switch( GetUserUnits() ) { case EDA_UNITS::INCHES: msg = _( "inches" ); break; case EDA_UNITS::MILS: msg = _( "mils" ); break; @@ -667,7 +668,7 @@ void EDA_DRAW_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) WINDOW_SETTINGS* window = GetWindowSettings( aCfg ); - aCfg->m_System.units = static_cast( m_userUnits ); + aCfg->m_System.units = static_cast( GetUserUnits() ); aCfg->m_System.first_run_shown = m_firstRunDialogSetting; aCfg->m_System.max_undo_items = GetMaxUndoItems(); diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 50b009862c..86f434064d 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -158,10 +158,9 @@ void SCH_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) SCH_BASE_FRAME::SaveSettings( eeconfig() ); wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() ); - // TODO(JE) do we need to keep m_userUnits around? if( eeconfig() ) { - eeconfig()->m_System.units = static_cast( m_userUnits ); + eeconfig()->m_System.units = static_cast( GetUserUnits() ); eeconfig()->m_AuiPanels.show_schematic_hierarchy = hierarchy_pane.IsShown(); eeconfig()->m_AuiPanels.schematic_hierarchy_float = hierarchy_pane.IsFloating(); // Other parameters (hierarchy_panel_float_width, hierarchy_panel_float_height, diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index c13afd4a4d..9f27030bb5 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -1612,7 +1612,7 @@ void SIM_PLOT_FRAME::onShowNetlist( wxCommandEvent& event ) text->SetLexer( wxSTC_LEX_SPICE ); wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL ); - sizer->Add( text, 1, wxEXPAND ); + sizer->Add( text, 1, wxEXPAND | wxALL, 5 ); SetSizer( sizer ); Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( NETLIST_VIEW_DIALOG::onClose ), diff --git a/include/eda_base_frame.h b/include/eda_base_frame.h index 48375f5748..dbedc6d739 100644 --- a/include/eda_base_frame.h +++ b/include/eda_base_frame.h @@ -3,7 +3,7 @@ * * Copyright (C) 2009-2015 Jean-Pierre Charras, jp.charras wanadoo.fr * Copyright (C) 2011 Wayne Stambaugh - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -733,7 +733,6 @@ private: wxString m_mruPath; // Most recently used path. - EDA_UNITS m_userUnits; ORIGIN_TRANSFORMS m_originTransforms; // Default display origin transforms object. ///< Map containing the UI update handlers registered with wx for each action. diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index 0627b2a142..dccaefb458 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 CERN - * Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2017-2022 KiCad Developers, see AUTHORS.txt for contributors. * @author Jean-Pierre Charras, jp.charras at wanadoo.fr * * This program is free software; you can redistribute it and/or @@ -91,7 +91,7 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_mruImagePath( wxEmptyString ) { m_maximizeByDefault = true; - m_userUnits = EDA_UNITS::MILLIMETRES; + SetUserUnits( EDA_UNITS::MILLIMETRES ); m_showBorderAndTitleBlock = true; // true for reference drawings. DS_DATA_MODEL::GetTheInstance().m_EditMode = true; @@ -665,14 +665,14 @@ void PL_EDITOR_FRAME::DisplayGridMsg() wxString line; wxString gridformatter; - switch( m_userUnits ) + switch( GetUserUnits() ) { case EDA_UNITS::INCHES: gridformatter = "grid %.3f"; break; case EDA_UNITS::MILLIMETRES: gridformatter = "grid %.4f"; break; default: gridformatter = "grid %f"; break; } - double grid = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, m_userUnits, + double grid = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, GetUserUnits(), GetCanvas()->GetGAL()->GetGridSize().x ); line.Printf( gridformatter, grid );