From eeccbf98f467308d8d93e1ab80fe48ea49027a12 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 2 May 2014 14:19:48 +0000 Subject: [PATCH] Don't crash when dismissing expanded ribbon panel. The parent of wxRibbonPanel is not always a wxRibbonPage, it can also be the containing wxFrame itself if the panel is a temporarily expanded one created when the user clicks a panel reduced to a button. So don't rely on the cast of the parent to wxRibbonPage to always work. This is ugly but at least avoids a crash. Closes #16215. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76437 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/ribbon/panel.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ribbon/panel.cpp b/src/ribbon/panel.cpp index fd354bf38f..1e37b6c093 100644 --- a/src/ribbon/panel.cpp +++ b/src/ribbon/panel.cpp @@ -1100,7 +1100,9 @@ wxRect wxRibbonPanel::GetExpandedPosition(wxRect panel, void wxRibbonPanel::HideIfExpanded() { - wxStaticCast(m_parent, wxRibbonPage)->HideIfExpanded(); + wxRibbonPage* const containingPage = wxDynamicCast(m_parent, wxRibbonPage); + if (containingPage) + containingPage->HideIfExpanded(); } #endif // wxUSE_RIBBON