Update schematic when saving tuned value
Also avoids a known(!) crash when the existing item has been deleted while tuning. Fixes https://gitlab.com/kicad/code/kicad/issues/9502
This commit is contained in:
parent
f79cb382c4
commit
9e760512ac
|
@ -572,6 +572,22 @@ void SIM_PLOT_FRAME::AddTuner( SCH_SYMBOL* aSymbol )
|
|||
}
|
||||
}
|
||||
|
||||
void SIM_PLOT_FRAME::UpdateTunerValue( SCH_SYMBOL* aSymbol, const wxString& aValue )
|
||||
{
|
||||
for( auto& item : m_schematicFrame->GetScreen()->Items().OfType( SCH_SYMBOL_T ) )
|
||||
{
|
||||
if( item == aSymbol )
|
||||
{
|
||||
aSymbol->SetValue( aValue );
|
||||
|
||||
m_schematicFrame->UpdateItem( aSymbol, false, true );
|
||||
m_schematicFrame->OnModify();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::RemoveTuner( TUNER_SLIDER* aTuner, bool aErase )
|
||||
{
|
||||
|
|
|
@ -109,6 +109,15 @@ public:
|
|||
*/
|
||||
void RemoveTuner( TUNER_SLIDER* aTuner, bool aErase = true );
|
||||
|
||||
/**
|
||||
* Safely update the value of the associated symbol without dereferencing
|
||||
* the symbol.
|
||||
*
|
||||
* @param aSymbol pointer to the symbol needing updating
|
||||
* @param aValue new value of the symbol
|
||||
*/
|
||||
void UpdateTunerValue( SCH_SYMBOL* aSymbol, const wxString& aValue );
|
||||
|
||||
/**
|
||||
* Return the currently opened plot panel (or NULL if there is none).
|
||||
*/
|
||||
|
|
|
@ -185,8 +185,7 @@ void TUNER_SLIDER::onClose( wxCommandEvent& event )
|
|||
|
||||
void TUNER_SLIDER::onSave( wxCommandEvent& event )
|
||||
{
|
||||
/// @todo it will crash when component is removed; completely remove m_symbol
|
||||
m_symbol->GetField( VALUE_FIELD )->SetText( m_value.ToOrigString() );
|
||||
m_frame->UpdateTunerValue( m_symbol, m_value.ToOrigString() );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue