From a8e73cf92ca1225ab33192d5e477cfc935b71043 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 15 Dec 2022 14:25:25 +0000 Subject: [PATCH] Check for model existence in library. --- eeschema/dialogs/dialog_sim_model.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/eeschema/dialogs/dialog_sim_model.cpp b/eeschema/dialogs/dialog_sim_model.cpp index 5d2baf9591..9b91d1578e 100644 --- a/eeschema/dialogs/dialog_sim_model.cpp +++ b/eeschema/dialogs/dialog_sim_model.cpp @@ -176,7 +176,18 @@ bool DIALOG_SIM_MODEL::TransferDataToWindow() // Must be set before curModel() is used since the latter checks the combobox value. std::string modelName = SIM_MODEL::GetFieldValue( &m_fields, SIM_LIBRARY::NAME_FIELD ); - m_modelNameChoice->SetStringSelection( modelName ); + int modelIdx = m_modelNameChoice->FindString( modelName ); + + if( modelIdx == wxNOT_FOUND ) + { + DisplayErrorMessage( this, wxString::Format( _( "No model named '%s' in library." ), + modelName ) ); + m_modelNameChoice->SetSelection( -1 ); + } + else + { + m_modelNameChoice->SetSelection( modelIdx ); + } if( isIbisLoaded() && ( m_modelNameChoice->GetSelection() >= 0 ) ) {