diff --git a/common/widgets/unit_binder.cpp b/common/widgets/unit_binder.cpp index 176ad6e90e..ec0b72ac76 100644 --- a/common/widgets/unit_binder.cpp +++ b/common/widgets/unit_binder.cpp @@ -46,7 +46,6 @@ UNIT_BINDER::UNIT_BINDER( EDA_DRAW_FRAME* aParent, wxStaticText* aLabel, wxWindo UNIT_BINDER::UNIT_BINDER( UNITS_PROVIDER* aUnitsProvider, wxWindow* aEventSource, wxStaticText* aLabel, wxWindow* aValueCtrl, wxStaticText* aUnitLabel, bool aAllowEval, bool aBindFocusEvent ) : - m_eventSource( aEventSource ), m_bindFocusEvent( aBindFocusEvent ), m_label( aLabel ), m_valueCtrl( aValueCtrl ), @@ -99,10 +98,10 @@ UNIT_BINDER::UNIT_BINDER( UNITS_PROVIDER* aUnitsProvider, wxWindow* aEventSource this ); } - if( m_eventSource ) + if( aEventSource ) { - m_eventSource->Connect( UNITS_CHANGED, wxCommandEventHandler( UNIT_BINDER::onUnitsChanged ), - nullptr, this ); + aEventSource->Connect( UNITS_CHANGED, wxCommandEventHandler( UNIT_BINDER::onUnitsChanged ), + nullptr, this ); } } @@ -115,12 +114,6 @@ UNIT_BINDER::~UNIT_BINDER() this ); } - if( m_eventSource ) - { - m_eventSource->Disconnect( UNITS_CHANGED, wxCommandEventHandler( UNIT_BINDER::onUnitsChanged ), - nullptr, this ); - } - if( m_valueCtrl ) { m_valueCtrl->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( UNIT_BINDER::onSetFocus ), @@ -395,7 +388,7 @@ void UNIT_BINDER::SetValue( const wxString& aValue ) value += EDA_UNIT_UTILS::GetLabel( m_units, m_dataType ); } - + if( textEntry ) textEntry->SetValue( value ); else if( staticText ) diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index 2531e7fc18..4dfa8879ef 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -140,7 +140,7 @@ static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER void OnKifaceEnd() override; wxWindow* CreateKiWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, - int aCtlBits = 0 ) override + int aCtlBits = 0 ) override { switch( aClassId ) { @@ -204,9 +204,9 @@ static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER frame = aKiway->Player( FRAME_SCH, false ); if( frame ) - return new PANEL_SYM_EDITING_OPTIONS( aParent, frame, frame ); - else - return new PANEL_SYM_EDITING_OPTIONS( aParent, this, nullptr ); + SetUserUnits( frame->GetUserUnits() ); + + return new PANEL_SYM_EDITING_OPTIONS( aParent, this, frame ); } case PANEL_SYM_COLORS: @@ -231,9 +231,9 @@ static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER frame = aKiway->Player( FRAME_SCH_VIEWER, false ); if( frame ) - return new PANEL_EESCHEMA_EDITING_OPTIONS( aParent, frame, frame ); - else - return new PANEL_EESCHEMA_EDITING_OPTIONS( aParent, this, nullptr ); + SetUserUnits( frame->GetUserUnits() ); + + return new PANEL_EESCHEMA_EDITING_OPTIONS( aParent, this, frame ); } case PANEL_SCH_ANNO_OPTIONS: diff --git a/include/widgets/unit_binder.h b/include/widgets/unit_binder.h index 6f8fcc214b..a54a29dadd 100644 --- a/include/widgets/unit_binder.h +++ b/include/widgets/unit_binder.h @@ -221,7 +221,6 @@ protected: double setPrecision( double aValue, bool aValueUsesUserUnits ); protected: - wxWindow* m_eventSource; bool m_bindFocusEvent; ///< The bound widgets diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index aa325f6f1f..ecf9c6101b 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -86,7 +86,7 @@ static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER void OnKifaceEnd() override; wxWindow* CreateKiWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, - int aCtlBits = 0 ) override + int aCtlBits = 0 ) override { switch( aClassId ) { @@ -160,9 +160,9 @@ static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER frame = aKiway->Player( FRAME_PCB_EDITOR, false ); if( frame ) - return new PANEL_EDIT_OPTIONS( aParent, frame, frame, true ); - else - return new PANEL_EDIT_OPTIONS( aParent, this, nullptr, true ); + SetUserUnits( frame->GetUserUnits() ); + + return new PANEL_EDIT_OPTIONS( aParent, this, frame, true ); } case PANEL_FP_DEFAULT_VALUES: @@ -176,9 +176,9 @@ static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER frame = aKiway->Player( FRAME_PCB_EDITOR, false ); if( frame ) - return new PANEL_FP_EDITOR_DEFAULTS( aParent, frame ); - else - return new PANEL_FP_EDITOR_DEFAULTS( aParent, this ); + SetUserUnits( frame->GetUserUnits() ); + + return new PANEL_FP_EDITOR_DEFAULTS( aParent, this ); } case PANEL_FP_COLORS: @@ -203,9 +203,9 @@ static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER frame = aKiway->Player( FRAME_FOOTPRINT_VIEWER, false ); if( frame ) - return new PANEL_EDIT_OPTIONS( aParent, frame, frame, false ); - else - return new PANEL_EDIT_OPTIONS( aParent, this, nullptr, false ); + SetUserUnits( frame->GetUserUnits() ); + + return new PANEL_EDIT_OPTIONS( aParent, this, frame, false ); } case PANEL_PCB_COLORS: