Make sure measurements are updated from grid before saving workbook.

Also fixes a typo when loading measurements.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15909
This commit is contained in:
Jeff Young 2023-10-20 17:23:15 +01:00
parent fc22e602e2
commit 12118b6246
2 changed files with 12 additions and 2 deletions

View File

@ -1965,7 +1965,7 @@ bool SIMULATOR_FRAME_UI::loadJsonWorkbook( const wxString& aPath )
if( tab_js.contains( "traces" ) ) if( tab_js.contains( "traces" ) )
traceInfo[plotTab] = tab_js[ "traces" ]; traceInfo[plotTab] = tab_js[ "traces" ];
if( js.contains( "measurements" ) ) if( tab_js.contains( "measurements" ) )
{ {
for( const nlohmann::json& m_js : tab_js[ "measurements" ] ) for( const nlohmann::json& m_js : tab_js[ "measurements" ] )
plotTab->Measurements().emplace_back( m_js[ "expr" ], m_js[ "format" ] ); plotTab->Measurements().emplace_back( m_js[ "expr" ], m_js[ "format" ] );
@ -2097,6 +2097,8 @@ bool SIMULATOR_FRAME_UI::loadJsonWorkbook( const wxString& aPath )
bool SIMULATOR_FRAME_UI::SaveWorkbook( const wxString& aPath ) bool SIMULATOR_FRAME_UI::SaveWorkbook( const wxString& aPath )
{ {
updateMeasurementsFromGrid();
wxFileName filename = aPath; wxFileName filename = aPath;
filename.SetExt( WorkbookFileExtension ); filename.SetExt( WorkbookFileExtension );
@ -2351,7 +2353,7 @@ void SIMULATOR_FRAME_UI::onPlotClosed( wxAuiNotebookEvent& event )
} }
void SIMULATOR_FRAME_UI::onPlotChanging( wxAuiNotebookEvent& event ) void SIMULATOR_FRAME_UI::updateMeasurementsFromGrid()
{ {
if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() ) ) if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() ) )
{ {
@ -2368,6 +2370,12 @@ void SIMULATOR_FRAME_UI::onPlotChanging( wxAuiNotebookEvent& event )
} }
} }
} }
}
void SIMULATOR_FRAME_UI::onPlotChanging( wxAuiNotebookEvent& event )
{
updateMeasurementsFromGrid();
event.Skip(); event.Skip();
} }

View File

@ -273,6 +273,8 @@ private:
*/ */
void rebuildMeasurementsGrid(); void rebuildMeasurementsGrid();
void updateMeasurementsFromGrid();
/** /**
* Apply component values specified using tuner sliders to the current netlist. * Apply component values specified using tuner sliders to the current netlist.
*/ */