The original patch did properly recognize the case when all transient
source definition fields are empty, which is perfectly valid.
This commit is contained in:
Maciej Suminski 2018-01-17 10:37:54 +01:00
parent 590cac9d55
commit 60963fe2fc
1 changed files with 8 additions and 9 deletions

View File

@ -537,13 +537,11 @@ bool DIALOG_SPICE_MODEL::generatePowerSource( wxString& aTarget ) const
{ {
trans += "("; trans += "(";
auto isempty = [] ( wxTextCtrl* ctrl ) { auto first_empty = std::find_if( genericControls.begin(), genericControls.end(), empty );
return empty( ctrl ); auto first_not_empty = std::find_if( genericControls.begin(), genericControls.end(),
}; []( const wxTextCtrl* c ){ return !empty( c ); } );
auto first_empty = std::find_if( genericControls.begin(), genericControls.end(), isempty ); if( std::distance( first_not_empty, genericControls.end() ) == 0 )
if( std::distance( first_empty, genericControls.end() ) == 0 )
{ {
// all empty // all empty
useTrans = false; useTrans = false;
@ -558,10 +556,10 @@ bool DIALOG_SPICE_MODEL::generatePowerSource( wxString& aTarget ) const
return false; return false;
} }
else if( std::find_if_not( first_empty, genericControls.end(), else if( std::find_if_not( first_empty, genericControls.end(),
isempty ) != genericControls.end() ) empty ) != genericControls.end() )
{ {
DisplayError( nullptr, wxT( "You cannot leave interleaved blank " DisplayError( nullptr, wxT( "You cannot leave interleaved empty fields "
"spaces for the transient source" ) ); "when defining a transient source" ) );
return false; return false;
} }
else else
@ -581,6 +579,7 @@ bool DIALOG_SPICE_MODEL::generatePowerSource( wxString& aTarget ) const
if( useTrans ) if( useTrans )
aTarget += trans; aTarget += trans;
// Remove whitespaces from left and right side
aTarget.Trim( false ); aTarget.Trim( false );
aTarget.Trim( true ); aTarget.Trim( true );