Fix recently introduced crash on spin page of widgets sample

Attempting to change the style or alignment of the spin controls in the
widgets sample made the sample crash. This was caused by a8b4753
(Reconnect events to the widget after recreating it in the sample,
2024-02-19) which resulted in using windows that were previously
destroyed.

Fix this by calling NotifyWidgetRecreation() for each spin control only
after they were all recreated.

Closes #24487.
This commit is contained in:
PB
2024-04-18 21:14:20 +02:00
committed by Vadim Zeitlin
parent ee309e078a
commit 7c125d304d
+2 -5
View File
@@ -415,9 +415,6 @@ void SpinBtnWidgetsPage::CreateSpin()
m_spinbtn = new wxSpinButton(this, SpinBtnPage_SpinBtn,
wxDefaultPosition, wxDefaultSize,
flags);
NotifyWidgetRecreation(m_spinbtn);
m_spinbtn->SetValue(val);
m_spinbtn->SetRange(m_min, m_max);
@@ -427,14 +424,14 @@ void SpinBtnWidgetsPage::CreateSpin()
flags | textFlags,
m_min, m_max, val);
NotifyWidgetRecreation(m_spinctrl);
m_spinctrldbl = new wxSpinCtrlDouble(this, SpinBtnPage_SpinCtrlDouble,
wxString::Format("%d", val),
wxDefaultPosition, wxDefaultSize,
flags | textFlags,
m_min, m_max, val, 0.1);
NotifyWidgetRecreation(m_spinbtn);
NotifyWidgetRecreation(m_spinctrl);
NotifyWidgetRecreation(m_spinctrldbl);
// Add spacers, labels and spin controls to the sizer.