From 2dfdf0682f94d6a59ae511aa6af8e16d599d0c97 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 3 Oct 2023 12:54:34 +0100 Subject: [PATCH] Don't ask for empty data. --- eeschema/sim/ngspice.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/eeschema/sim/ngspice.cpp b/eeschema/sim/ngspice.cpp index 180a7f2222..460ec454dd 100644 --- a/eeschema/sim/ngspice.cpp +++ b/eeschema/sim/ngspice.cpp @@ -122,9 +122,11 @@ std::vector NGSPICE::GetComplexVector( const std::string& aName, int aM { LOCALE_IO c_locale; // ngspice works correctly only with C locale std::vector data; - vector_info* vi = m_ngGet_Vec_Info( (char*) aName.c_str() ); - if( vi ) + if( aMaxLen == 0 ) + return data; + + if( vector_info* vi = m_ngGet_Vec_Info( (char*) aName.c_str() ) ) { int length = aMaxLen < 0 ? vi->v_length : std::min( aMaxLen, vi->v_length ); data.reserve( length ); @@ -149,9 +151,11 @@ std::vector NGSPICE::GetRealVector( const std::string& aName, int aMaxLe { LOCALE_IO c_locale; // ngspice works correctly only with C locale std::vector data; - vector_info* vi = m_ngGet_Vec_Info( (char*) aName.c_str() ); - if( vi ) + if( aMaxLen == 0 ) + return data; + + if( vector_info* vi = m_ngGet_Vec_Info( (char*) aName.c_str() ) ) { int length = aMaxLen < 0 ? vi->v_length : std::min( aMaxLen, vi->v_length ); data.reserve( length ); @@ -179,9 +183,11 @@ std::vector NGSPICE::GetImaginaryVector( const std::string& aName, int a { LOCALE_IO c_locale; // ngspice works correctly only with C locale std::vector data; - vector_info* vi = m_ngGet_Vec_Info( (char*) aName.c_str() ); - if( vi ) + if( aMaxLen == 0 ) + return data; + + if( vector_info* vi = m_ngGet_Vec_Info( (char*) aName.c_str() ) ) { int length = aMaxLen < 0 ? vi->v_length : std::min( aMaxLen, vi->v_length ); data.reserve( length ); @@ -201,9 +207,11 @@ std::vector NGSPICE::GetGainVector( const std::string& aName, int aMaxLe { LOCALE_IO c_locale; // ngspice works correctly only with C locale std::vector data; - vector_info* vi = m_ngGet_Vec_Info( (char*) aName.c_str() ); - if( vi ) + if( aMaxLen == 0 ) + return data; + + if( vector_info* vi = m_ngGet_Vec_Info( (char*) aName.c_str() ) ) { int length = aMaxLen < 0 ? vi->v_length : std::min( aMaxLen, vi->v_length ); data.reserve( length ); @@ -228,9 +236,11 @@ std::vector NGSPICE::GetPhaseVector( const std::string& aName, int aMaxL { LOCALE_IO c_locale; // ngspice works correctly only with C locale std::vector data; - vector_info* vi = m_ngGet_Vec_Info( (char*) aName.c_str() ); - if( vi ) + if( aMaxLen == 0 ) + return data; + + if( vector_info* vi = m_ngGet_Vec_Info( (char*) aName.c_str() ) ) { int length = aMaxLen < 0 ? vi->v_length : std::min( aMaxLen, vi->v_length ); data.reserve( length );