Bug fixes for tuning.
1) Don't save SCH_ITEM pointers in long-lived structures. Use KIIDs instead. 2) Use the correct sheet for the referenced item, not the current sheet.
This commit is contained in:
parent
604d7a72d6
commit
bfd3b40672
|
@ -601,27 +601,27 @@ void SIM_PLOT_FRAME::AddTuner( SCH_SYMBOL* aSymbol )
|
|||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::UpdateTunerValue( SCH_SYMBOL* aSymbol, const wxString& aValue )
|
||||
void SIM_PLOT_FRAME::UpdateTunerValue( const KIID& aSymbol, const wxString& aValue )
|
||||
{
|
||||
for( EDA_ITEM* item : m_schematicFrame->GetScreen()->Items().OfType( SCH_SYMBOL_T ) )
|
||||
SCH_SHEET_PATH sheet;
|
||||
SCH_ITEM* item = m_schematicFrame->Schematic().GetSheets().GetItem( aSymbol, &sheet );
|
||||
SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item );
|
||||
|
||||
if( symbol )
|
||||
{
|
||||
if( item == aSymbol )
|
||||
{
|
||||
SIM_LIB_MGR mgr( &Prj() );
|
||||
SIM_MODEL& model = mgr.CreateModel( &m_schematicFrame->GetCurrentSheet(),
|
||||
*aSymbol ).model;
|
||||
SIM_LIB_MGR mgr( &Prj() );
|
||||
SIM_MODEL& model = mgr.CreateModel( &sheet, *symbol ).model;
|
||||
|
||||
const SIM_MODEL::PARAM* tunerParam = model.GetTunerParam();
|
||||
const SIM_MODEL::PARAM* tunerParam = model.GetTunerParam();
|
||||
|
||||
if( !tunerParam )
|
||||
return;
|
||||
if( !tunerParam )
|
||||
return;
|
||||
|
||||
model.SetParamValue( tunerParam->info.name, std::string( aValue.ToUTF8() ) );
|
||||
model.WriteFields( aSymbol->GetFields() );
|
||||
model.SetParamValue( tunerParam->info.name, std::string( aValue.ToUTF8() ) );
|
||||
model.WriteFields( symbol->GetFields() );
|
||||
|
||||
m_schematicFrame->UpdateItem( aSymbol, false, true );
|
||||
m_schematicFrame->OnModify();
|
||||
}
|
||||
m_schematicFrame->UpdateItem( symbol, false, true );
|
||||
m_schematicFrame->OnModify();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -112,11 +112,11 @@ public:
|
|||
* Safely update a field of the associated symbol without dereferencing
|
||||
* the symbol.
|
||||
*
|
||||
* @param aSymbol pointer to the symbol needing updating
|
||||
* @param aSymbol id of the symbol needing updating
|
||||
* @param aId id of the symbol field
|
||||
* @param aValue new value of the symbol field
|
||||
*/
|
||||
void UpdateTunerValue( SCH_SYMBOL* aSymbol, const wxString& aValue );
|
||||
void UpdateTunerValue( const KIID& aSymbol, const wxString& aValue );
|
||||
|
||||
/**
|
||||
* Return the currently opened plot panel (or NULL if there is none).
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
TUNER_SLIDER::TUNER_SLIDER( SIM_PLOT_FRAME* aFrame, wxWindow* aParent, SCH_SYMBOL* aSymbol ) :
|
||||
TUNER_SLIDER_BASE( aParent ),
|
||||
m_symbol( aSymbol ),
|
||||
m_symbol( aSymbol->m_Uuid ),
|
||||
m_min( 0.0 ),
|
||||
m_max( 0.0 ),
|
||||
m_value( 0.0 ),
|
||||
|
|
|
@ -92,13 +92,15 @@ private:
|
|||
///< Timer that restarts the simulation after the slider value has changed
|
||||
wxTimer m_simTimer;
|
||||
|
||||
SCH_SYMBOL* m_symbol;
|
||||
KIID m_symbol;
|
||||
const SPICE_ITEM* m_item;
|
||||
|
||||
SPICE_VALUE m_min, m_max, m_value;
|
||||
bool m_changed;
|
||||
SPICE_VALUE m_min;
|
||||
SPICE_VALUE m_max;
|
||||
SPICE_VALUE m_value;
|
||||
bool m_changed;
|
||||
|
||||
SIM_PLOT_FRAME* m_frame;
|
||||
SIM_PLOT_FRAME* m_frame;
|
||||
};
|
||||
|
||||
#endif /* TUNER_SLIDER_H */
|
||||
|
|
Loading…
Reference in New Issue