From 0fa1ddb368cd131c8334ebbe9c5ddf9ebcf2f0f6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 21 Jan 2016 22:49:42 +0100 Subject: [PATCH] Check that the dialog had been created in wxTextEntryDialog Don't crash if setter functions are called before Create() which could happen for the default-constructed dialogs. See #17291. --- src/generic/textdlgg.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/generic/textdlgg.cpp b/src/generic/textdlgg.cpp index ce24c6fd59..97c50bad44 100644 --- a/src/generic/textdlgg.cpp +++ b/src/generic/textdlgg.cpp @@ -152,6 +152,8 @@ void wxTextEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event) ) void wxTextEntryDialog::SetMaxLength(unsigned long len) { + wxCHECK_RET( m_textctrl, wxS("Must be created first") ); + m_textctrl->SetMaxLength(len); } @@ -159,7 +161,10 @@ void wxTextEntryDialog::SetValue(const wxString& val) { m_value = val; - m_textctrl->SetValue(val); + if ( m_textctrl ) + { + m_textctrl->SetValue(val); + } } #if wxUSE_VALIDATORS @@ -178,6 +183,8 @@ void wxTextEntryDialog::SetTextValidator( wxTextValidatorStyle style ) void wxTextEntryDialog::SetTextValidator( const wxTextValidator& validator ) { + wxCHECK_RET( m_textctrl, wxS("Must be created first") ); + m_textctrl->SetValidator( validator ); }