diff --git a/eeschema/sim/sim_plot_tab.cpp b/eeschema/sim/sim_plot_tab.cpp index 6f7852c5f6..ee5a529c77 100644 --- a/eeschema/sim/sim_plot_tab.cpp +++ b/eeschema/sim/sim_plot_tab.cpp @@ -283,17 +283,13 @@ void CURSOR::doSetCoordX( double aValue ) int minIdx = maxIdx - 1; // Out of bounds checks - if( minIdx < 0 ) + if( minIdx < 0 || maxIdx >= (int) dataX.size() ) { - minIdx = 0; - maxIdx = 1; - m_coords.x = dataX[0]; - } - else if( maxIdx >= (int) dataX.size() ) - { - maxIdx = dataX.size() - 1; - minIdx = maxIdx - 1; - m_coords.x = dataX[maxIdx]; + // Simulation may not be complete yet, or we may have a cursor off the beginning or end + // of the data. Either way, that's where the user put it. Don't second guess them; just + // leave its y value undefined. + m_coords.y = NAN; + return; } const double leftX = dataX[minIdx]; diff --git a/eeschema/sim/simulator_frame_ui.cpp b/eeschema/sim/simulator_frame_ui.cpp index 47419d5e1a..e030eb3539 100644 --- a/eeschema/sim/simulator_frame_ui.cpp +++ b/eeschema/sim/simulator_frame_ui.cpp @@ -2438,7 +2438,7 @@ void SIMULATOR_FRAME_UI::updatePlotCursors() auto formatValue = [this]( double aValue, int aCursorId, int aCol ) -> wxString { - if( !m_simulatorFrame->SimFinished() && aCol == 1 ) + if( ( !m_simulatorFrame->SimFinished() && aCol == 1 ) || std::isnan( aValue ) ) return wxS( "--" ); else return SPICE_VALUE( aValue ).ToString( m_cursorFormats[ aCursorId ][ aCol ] );