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.
This commit is contained in:
PB
2024-07-04 01:29:23 +02:00
committed by Vadim Zeitlin
parent b808f4d107
commit 19ec50bfa5
+8 -5
View File
@@ -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();