Update associated data structures after changing trace colour.

Also removes likely benign but never-the-less useless grid even processing
during rebuilding of the grids.

Fixes https://gitlab.com/kicad/code/kicad/issues/13956
This commit is contained in:
Jeff Young 2023-02-17 00:45:48 +00:00
parent 614755f24e
commit 8b1318c92f
2 changed files with 34 additions and 0 deletions

View File

@ -324,8 +324,28 @@ void MEASUREMENTS_GRID_TRICKS::doPopupSelection( wxCommandEvent& event )
} }
class SUPPRESS_GRID_CELL_EVENTS
{
public:
SUPPRESS_GRID_CELL_EVENTS( SIM_PLOT_FRAME* aFrame ) :
m_frame( aFrame )
{
m_frame->m_SuppressGridEvents++;
}
~SUPPRESS_GRID_CELL_EVENTS()
{
m_frame->m_SuppressGridEvents--;
}
private:
SIM_PLOT_FRAME* m_frame;
};
SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
SIM_PLOT_FRAME_BASE( aParent ), SIM_PLOT_FRAME_BASE( aParent ),
m_SuppressGridEvents( 0 ),
m_lastSimPlot( nullptr ), m_lastSimPlot( nullptr ),
m_darkMode( true ), m_darkMode( true ),
m_plotNumber( 0 ), m_plotNumber( 0 ),
@ -646,6 +666,8 @@ void SIM_PLOT_FRAME::setSubWindowsSashSize()
void SIM_PLOT_FRAME::rebuildSignalsGrid( wxString aFilter ) void SIM_PLOT_FRAME::rebuildSignalsGrid( wxString aFilter )
{ {
SUPPRESS_GRID_CELL_EVENTS raii( this );
m_signalsGrid->ClearRows(); m_signalsGrid->ClearRows();
if( aFilter.IsEmpty() ) if( aFilter.IsEmpty() )
@ -970,6 +992,9 @@ void updateRangeUnits( wxString* aRange, const wxString& aUnits )
void SIM_PLOT_FRAME::onSignalsGridCellChanged( wxGridEvent& aEvent ) void SIM_PLOT_FRAME::onSignalsGridCellChanged( wxGridEvent& aEvent )
{ {
if( m_SuppressGridEvents > 0 )
return;
int row = aEvent.GetRow(); int row = aEvent.GetRow();
int col = aEvent.GetCol(); int col = aEvent.GetCol();
wxString text = m_signalsGrid->GetCellValue( row, col ); wxString text = m_signalsGrid->GetCellValue( row, col );
@ -1055,6 +1080,9 @@ void SIM_PLOT_FRAME::onSignalsGridCellChanged( wxGridEvent& aEvent )
void SIM_PLOT_FRAME::onCursorsGridCellChanged( wxGridEvent& aEvent ) void SIM_PLOT_FRAME::onCursorsGridCellChanged( wxGridEvent& aEvent )
{ {
if( m_SuppressGridEvents > 0 )
return;
SIM_PLOT_PANEL* plotPanel = GetCurrentPlot(); SIM_PLOT_PANEL* plotPanel = GetCurrentPlot();
if( !plotPanel ) if( !plotPanel )
@ -1788,6 +1816,7 @@ bool SIM_PLOT_FRAME::LoadWorkbook( const wxString& aPath )
wxColour color; wxColour color;
color.Set( item ); color.Set( item );
trace->SetTraceColour( color ); trace->SetTraceColour( color );
plotPanel->UpdateTraceStyle( trace );
} }
else if( item.StartsWith( wxS( "cursor1" ) ) ) else if( item.StartsWith( wxS( "cursor1" ) ) )
{ {
@ -2165,6 +2194,8 @@ void SIM_PLOT_FRAME::doCloseWindow()
void SIM_PLOT_FRAME::updateCursors() void SIM_PLOT_FRAME::updateCursors()
{ {
SUPPRESS_GRID_CELL_EVENTS raii( this );
m_cursorsGrid->ClearRows(); m_cursorsGrid->ClearRows();
SIM_PLOT_PANEL* plotPanel = GetCurrentPlot(); SIM_PLOT_PANEL* plotPanel = GetCurrentPlot();

View File

@ -355,6 +355,9 @@ private:
// frame is initialized (end of the Ctor) // frame is initialized (end of the Ctor)
void setSubWindowsSashSize(); void setSubWindowsSashSize();
public:
int m_SuppressGridEvents;
private: private:
SCH_EDIT_FRAME* m_schematicFrame; SCH_EDIT_FRAME* m_schematicFrame;
std::shared_ptr<NGSPICE_CIRCUIT_MODEL> m_circuitModel; std::shared_ptr<NGSPICE_CIRCUIT_MODEL> m_circuitModel;