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
This commit is contained in:
Vadim Zeitlin
2014-05-02 14:19:48 +00:00
parent 605e637f47
commit eeccbf98f4

View File

@@ -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