Fix store-in-value bugs.

1) Always honour the dialog checkbox value.
2) Don't expect the absence of the primary parameter in Sim.Params to
   mean that Value stores it.  It might be the default parameter value.
3) Update spiceTypeInfo when matching legacy data to an internal model.
4) Initialize the store-in-value checkbox depending on whether or not
   we found the primary parameter in the Value field.
This commit is contained in:
Jeff Young 2023-01-03 16:58:36 +00:00
parent 9b9795a87d
commit 9583b28063
6 changed files with 21 additions and 18 deletions

View File

@ -281,7 +281,8 @@ bool DIALOG_SIM_MODEL<T_symbol, T_field>::TransferDataToWindow()
m_curModelTypeOfDeviceType[deviceTypeT] = type;
}
curModel().SetIsStoredInValue( storeInValue );
if( storeInValue )
curModel().SetIsStoredInValue( true );
m_saveInValueCheckbox->SetValue( curModel().IsStoredInValue() );
@ -341,6 +342,8 @@ bool DIALOG_SIM_MODEL<T_symbol, T_field>::TransferDataFromWindow()
}
}
curModel().SetIsStoredInValue( m_saveInValueCheckbox->GetValue() );
curModel().WriteFields( m_fields );
return true;
@ -1266,13 +1269,6 @@ void DIALOG_SIM_MODEL<T_symbol, T_field>::onPinAssignmentsGridSize( wxSizeEvent&
}
template <typename T_symbol, typename T_field>
void DIALOG_SIM_MODEL<T_symbol, T_field>::onSaveInValueCheckbox( wxCommandEvent& aEvent )
{
curModel().SetIsStoredInValue( m_saveInValueCheckbox->GetValue() );
}
template <typename T_symbol, typename T_field>
void DIALOG_SIM_MODEL<T_symbol, T_field>::onParamGridSetFocus( wxFocusEvent& aEvent )
{

View File

@ -106,7 +106,6 @@ private:
void onPageChanging( wxNotebookEvent& event ) override;
void onPinAssignmentsGridCellChange( wxGridEvent& aEvent ) override;
void onPinAssignmentsGridSize( wxSizeEvent& aEvent ) override;
void onSaveInValueCheckbox( wxCommandEvent& aEvent ) override;
void onDifferentialCheckbox( wxCommandEvent& event ) override;
void onSizeParamGrid( wxSizeEvent& event ) override;

View File

@ -353,7 +353,6 @@ DIALOG_SIM_MODEL_BASE::DIALOG_SIM_MODEL_BASE( wxWindow* parent, wxWindowID id, c
m_typeChoice->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onTypeChoice ), NULL, this );
m_modelNotebook->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, wxNotebookEventHandler( DIALOG_SIM_MODEL_BASE::onPageChanging ), NULL, this );
m_paramGridMgr->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SIM_MODEL_BASE::onSizeParamGrid ), NULL, this );
m_saveInValueCheckbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onSaveInValueCheckbox ), NULL, this );
m_pinAssignmentsGrid->Connect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_SIM_MODEL_BASE::onPinAssignmentsGridCellChange ), NULL, this );
m_pinAssignmentsGrid->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SIM_MODEL_BASE::onPinAssignmentsGridSize ), NULL, this );
}
@ -389,7 +388,6 @@ DIALOG_SIM_MODEL_BASE::~DIALOG_SIM_MODEL_BASE()
m_typeChoice->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onTypeChoice ), NULL, this );
m_modelNotebook->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, wxNotebookEventHandler( DIALOG_SIM_MODEL_BASE::onPageChanging ), NULL, this );
m_paramGridMgr->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SIM_MODEL_BASE::onSizeParamGrid ), NULL, this );
m_saveInValueCheckbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onSaveInValueCheckbox ), NULL, this );
m_pinAssignmentsGrid->Disconnect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_SIM_MODEL_BASE::onPinAssignmentsGridCellChange ), NULL, this );
m_pinAssignmentsGrid->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SIM_MODEL_BASE::onPinAssignmentsGridSize ), NULL, this );

View File

@ -1718,7 +1718,6 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnCheckBox">onSaveInValueCheckbox</event>
</object>
</object>
<object class="sizeritem" expanded="1">

View File

@ -111,7 +111,6 @@ class DIALOG_SIM_MODEL_BASE : public DIALOG_SHIM
virtual void onTypeChoice( wxCommandEvent& event ) { event.Skip(); }
virtual void onPageChanging( wxNotebookEvent& event ) { event.Skip(); }
virtual void onSizeParamGrid( wxSizeEvent& event ) { event.Skip(); }
virtual void onSaveInValueCheckbox( wxCommandEvent& event ) { event.Skip(); }
virtual void onPinAssignmentsGridCellChange( wxGridEvent& event ) { event.Skip(); }
virtual void onPinAssignmentsGridSize( wxSizeEvent& event ) { event.Skip(); }

View File

@ -1040,7 +1040,19 @@ void SIM_MODEL::doReadDataFields( const std::vector<T>* aFields,
std::string paramsField = GetFieldValue( aFields, PARAMS_FIELD );
if( !m_serializer->ParseParams( paramsField ) )
m_serializer->ParseValue( GetFieldValue( aFields, VALUE_FIELD ) );
{
// We're relying on the absence of the primary parameter in PARAMS_FIELD to signal that
// it's stored in VALUE_FIELD. But that's a poor determinant as it may just be that the
// primary parameter is its default value. So see if we have anything in VALUE_FIELD,
// but don't be belligerent about it.
try
{
m_serializer->ParseValue( GetFieldValue( aFields, VALUE_FIELD ) );
}
catch( ... )
{
}
}
}
@ -1615,19 +1627,19 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol, const PROJECT* aProject )
if( tokenizer.HasMoreTokens() )
{
wxString spiceType = tokenizer.GetNextToken();
spiceType.MakeUpper();
spiceTypeInfo.m_Text = tokenizer.GetNextToken();
spiceTypeInfo.m_Text.MakeUpper();
for( SIM_MODEL::TYPE type : SIM_MODEL::TYPE_ITERATOR() )
{
if( spiceDeviceType == SIM_MODEL::SpiceInfo( type ).itemType
&& spiceType == SIM_MODEL::SpiceInfo( type ).inlineTypeString )
&& spiceTypeInfo.m_Text == SIM_MODEL::SpiceInfo( type ).inlineTypeString )
{
try
{
std::unique_ptr<SIM_MODEL> model = SIM_MODEL::Create( type );
if( spiceType == wxT( "DC" ) && tokenizer.CountTokens() == 1 )
if( spiceTypeInfo.m_Text == wxT( "DC" ) && tokenizer.CountTokens() == 1 )
{
valueField->SetText( tokenizer.GetNextToken() );
modelFromValueField = false;