From 3d0fe8e2c6b5d8f14e077873f0c2d369d0c1cfc9 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 26 May 2021 12:38:23 +0100 Subject: [PATCH] Only initialize VALIDATOR if we're using it. It appears to get called by the wxWidgets framework sometimes even when invisible/unenabled. Fixes https://gitlab.com/kicad/code/kicad/issues/8483 --- eeschema/dialogs/dialog_edit_one_field.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/eeschema/dialogs/dialog_edit_one_field.cpp b/eeschema/dialogs/dialog_edit_one_field.cpp index d34330eab8..3285a2b6f9 100644 --- a/eeschema/dialogs/dialog_edit_one_field.cpp +++ b/eeschema/dialogs/dialog_edit_one_field.cpp @@ -81,9 +81,7 @@ DIALOG_EDIT_ONE_FIELD::~DIALOG_EDIT_ONE_FIELD() void DIALOG_EDIT_ONE_FIELD::init() { SCH_BASE_FRAME* parent = GetParent(); - bool isSymbolEditor = parent->IsType( FRAME_SCH_SYMBOL_EDITOR ); - - m_TextCtrl->SetValidator( SCH_FIELD_VALIDATOR( isSymbolEditor, m_fieldId, &m_text ) ); + bool isSymbolEditor = parent && parent->IsType( FRAME_SCH_SYMBOL_EDITOR ); // Disable options for graphic text editing which are not needed for fields. m_CommonConvert->Show( false ); @@ -100,13 +98,16 @@ void DIALOG_EDIT_ONE_FIELD::init() if( use_validator ) { - m_StyledTextCtrl->Show( false ); + m_TextCtrl->SetValidator( SCH_FIELD_VALIDATOR( isSymbolEditor, m_fieldId, &m_text ) ); SetInitialFocus( m_TextCtrl ); + + m_StyledTextCtrl->Show( false ); } else { - m_TextCtrl->Show( false ); SetInitialFocus( m_StyledTextCtrl ); + + m_TextCtrl->Show( false ); } // Show the footprint selection dialog if this is the footprint field.