From: Robert Roebling Date: Sat, 21 Aug 2010 09:39:09 +0000 (+0000) Subject: Fix crash by checking if icon is valid before drawing it, fixes #12376: PATCH for... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f6ac1f4b386c464b5b610b5e72cfc0453333a806 Fix crash by checking if icon is valid before drawing it, fixes #12376: PATCH for Ribbon crash git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65372 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/ribbon/art_aui.cpp b/src/ribbon/art_aui.cpp index a0f40869f5..d127da85bc 100644 --- a/src/ribbon/art_aui.cpp +++ b/src/ribbon/art_aui.cpp @@ -387,9 +387,12 @@ void wxRibbonAUIArtProvider::DrawTab(wxDC& dc, icon = tab.page->GetIcon(); if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) == 0) { + if(icon.IsOk()) + { int x = tab.rect.x + (tab.rect.width - icon.GetWidth()) / 2; dc.DrawBitmap(icon, x, tab.rect.y + 1 + (tab.rect.height - 1 - icon.GetHeight()) / 2, true); + } } } if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) diff --git a/src/ribbon/art_msw.cpp b/src/ribbon/art_msw.cpp index ad494d5863..562c89772a 100644 --- a/src/ribbon/art_msw.cpp +++ b/src/ribbon/art_msw.cpp @@ -1035,11 +1035,14 @@ void wxRibbonMSWArtProvider::DrawTab( if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) { wxBitmap icon = tab.page->GetIcon(); + if(icon.IsOk()) + { int x = tab.rect.x + 4; if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) == 0) x = tab.rect.x + (tab.rect.width - icon.GetWidth()) / 2; dc.DrawBitmap(icon, x, tab.rect.y + 1 + (tab.rect.height - 1 - icon.GetHeight()) / 2, true); + } } if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) {