From 59b9edf0b390f9cd8e80475913ec94675ae8a427 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Tue, 14 May 2002 11:28:13 +0000 Subject: [PATCH] Initialized the controls on the widgets spinbutton page and checked for NULL in one of the event handlers, since on the Mac the event handler may be called before the control is properly initialized Tested for an empty string in Mac's textctrl.cpp else we get a crash if there is nothing in the text control git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15555 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/widgets/spinbtn.cpp | 11 ++++++++++- src/mac/carbon/textctrl.cpp | 3 ++- src/mac/textctrl.cpp | 3 ++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/samples/widgets/spinbtn.cpp b/samples/widgets/spinbtn.cpp index 62b68b0916..609870b89a 100644 --- a/samples/widgets/spinbtn.cpp +++ b/samples/widgets/spinbtn.cpp @@ -165,6 +165,13 @@ SpinBtnWidgetsPage::SpinBtnWidgetsPage(wxNotebook *notebook, wxImageList *imaglist) : WidgetsPage(notebook) { + m_chkVert = NULL; + m_chkWrap = NULL; + m_spinbtn = NULL; + m_spinctrl = NULL; + m_textValue = NULL; + m_textMin = NULL; + m_textMax = NULL; imaglist->Add(wxBitmap(spinbtn_xpm)); // init everything @@ -410,6 +417,8 @@ void SpinBtnWidgetsPage::OnSpinBtnDown(wxCommandEvent& event) void SpinBtnWidgetsPage::OnSpinCtrl(wxCommandEvent& event) { + if (!m_spinctrl) + return; int value = event.GetInt(); wxASSERT_MSG( value == m_spinctrl->GetValue(), @@ -417,4 +426,4 @@ void SpinBtnWidgetsPage::OnSpinCtrl(wxCommandEvent& event) wxLogMessage(_T("Spin control value changed, now %d"), value); } -#endif \ No newline at end of file +#endif diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index f7b6eee18a..9f92ee77bd 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -816,7 +816,8 @@ wxString wxTextCtrl::GetValue() const else { actualsize = GetHandleSize( theText ) ; - strncpy( wxBuffer , *theText , actualsize ) ; + if (actualsize != 0) + strncpy( wxBuffer , *theText , actualsize ) ; DisposeHandle( theText ) ; } } diff --git a/src/mac/textctrl.cpp b/src/mac/textctrl.cpp index f7b6eee18a..9f92ee77bd 100644 --- a/src/mac/textctrl.cpp +++ b/src/mac/textctrl.cpp @@ -816,7 +816,8 @@ wxString wxTextCtrl::GetValue() const else { actualsize = GetHandleSize( theText ) ; - strncpy( wxBuffer , *theText , actualsize ) ; + if (actualsize != 0) + strncpy( wxBuffer , *theText , actualsize ) ; DisposeHandle( theText ) ; } } -- 2.45.2