From c582cf5946a274b919684e9618cc855b2074c7e8 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 4 Jun 2015 17:44:56 +0200 Subject: [PATCH] Fix Bug #1445851: libedit field editor unnecessarily replaces spaces with underscores. Only reference and mainly value (in fact symbol name in lib) do not accept spaces in schematic libraries. --- eeschema/dialogs/dialog_edit_one_field.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/eeschema/dialogs/dialog_edit_one_field.cpp b/eeschema/dialogs/dialog_edit_one_field.cpp index 13bd957b95..d3439da381 100644 --- a/eeschema/dialogs/dialog_edit_one_field.cpp +++ b/eeschema/dialogs/dialog_edit_one_field.cpp @@ -161,8 +161,26 @@ void DIALOG_LIB_EDIT_ONE_FIELD::initDlg() wxString DIALOG_LIB_EDIT_ONE_FIELD::GetTextField() { wxString line = m_TextValue->GetValue(); - // Spaces are not allowed in fields, so replace them by '_' - line.Replace( wxT( " " ), wxT( "_" ) ); + + // Spaces are not allowed in reference or value + if( m_field->GetId() == REFERENCE || m_field->GetId() == VALUE ) + { + if( line.Replace( wxT( " " ), wxT( "_" ) ) ) + { + wxString msg; + msg.Printf( _( + "Whitespace is not permitted inside references or values (symbol names in lib).\n" + "The text you entered has been converted to use underscores: %s" ), + line + ); + wxMessageDialog dlg( this, msg ); + dlg.ShowModal(); + } + } + + // Prevent the message from appearing twice by restuffing the text box. + m_TextValue->SetValue( line ); + return line; }