Don't pass a FRAME-based UNITS_PROVIDER to a modeless dialog.

(The dialog may outlive said frame.)
Should fix Sentry KICAD-3A.

(cherry picked from commit 9b4627e782)
This commit is contained in:
Jeff Young 2023-04-03 17:10:15 +01:00
parent 927b5ae707
commit a21e7a5eee
4 changed files with 21 additions and 29 deletions

View File

@ -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,9 +98,9 @@ UNIT_BINDER::UNIT_BINDER( UNITS_PROVIDER* aUnitsProvider, wxWindow* aEventSource
this );
}
if( m_eventSource )
if( aEventSource )
{
m_eventSource->Connect( UNITS_CHANGED, wxCommandEventHandler( UNIT_BINDER::onUnitsChanged ),
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 ),

View File

@ -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:

View File

@ -221,7 +221,6 @@ protected:
double setPrecision( double aValue, bool aValueUsesUserUnits );
protected:
wxWindow* m_eventSource;
bool m_bindFocusEvent;
///< The bound widgets

View File

@ -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,8 +176,8 @@ 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
SetUserUnits( frame->GetUserUnits() );
return new PANEL_FP_EDITOR_DEFAULTS( aParent, this );
}
@ -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: