From 19ec50bfa5827f7f5b947cde2f24b767ef97df94 Mon Sep 17 00:00:00 2001 From: PB Date: Sun, 30 Jun 2024 23:13:57 +0200 Subject: [PATCH] Fix crash on static page of widgets sample Attempting to change the style or alignment of the static text in the widgets sample made the sample crash. The bug cause was the same as in 7c125d3 (Fix crash on spin page of widgets sample, 2024-04-18), i.e., a8b4753 (Reconnect events to the widget after recreating it in the sample, 2024-02-19). Fix the issue by calling NotifyWidgetRecreation() for each control only after they were all recreated. Closes #24656. Closes #24660. --- samples/widgets/static.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/samples/widgets/static.cpp b/samples/widgets/static.cpp index abb59ca2c8..cded6d1d07 100644 --- a/samples/widgets/static.cpp +++ b/samples/widgets/static.cpp @@ -525,13 +525,10 @@ void StaticWidgetsPage::CreateStatic() #endif // wxUSE_MARKUP } - NotifyWidgetRecreation(m_statText); m_statText->SetToolTip("Tooltip for a label inside the box"); #if wxUSE_MARKUP - NotifyWidgetRecreation(m_statMarkup); - m_statMarkup->SetLabelMarkup(m_textLabelWithMarkup->GetValue()); if ( m_chkGreen->GetValue() ) @@ -542,8 +539,6 @@ void StaticWidgetsPage::CreateStatic() m_statLine = new wxStaticLine(staticBox, wxID_ANY, wxDefaultPosition, wxDefaultSize, isVert ? wxLI_VERTICAL : wxLI_HORIZONTAL); - - NotifyWidgetRecreation(m_statLine); #endif // wxUSE_STATLINE m_sizerStatBox->Add(m_statText, 0, wxGROW); @@ -554,6 +549,14 @@ void StaticWidgetsPage::CreateStatic() m_sizerStatBox->Add(m_statMarkup); #endif // wxUSE_MARKUP + NotifyWidgetRecreation(m_statText); +#if wxUSE_MARKUP + NotifyWidgetRecreation(m_statMarkup); +#endif +#if wxUSE_STATLINE + NotifyWidgetRecreation(m_statLine); +#endif + m_sizerStatic->Add(m_sizerStatBox, 0, wxGROW); m_sizerStatic->Layout();