From 57c6f0fe5f31e15e0cf7992f8eb654c82c1b7994 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 3 Nov 2008 17:24:51 +0000 Subject: [PATCH] don't crash trying to draw buttons with invalid bitmaps (the real fix would be to avoid adding them to the toolbar in the first place, of course...) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56666 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/univ/toolbar.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/univ/toolbar.cpp b/src/univ/toolbar.cpp index 9b36cc74ac..7f81f0daa8 100644 --- a/src/univ/toolbar.cpp +++ b/src/univ/toolbar.cpp @@ -691,26 +691,26 @@ void wxToolBar::DoDraw(wxControlRenderer *renderer) { label = tool->GetLabel(); bitmap = tool->GetBitmap(); + + if ( !bitmap.IsOk() ) + { + // it's better not to draw anything than to assert inside + // drawing code as this results in an almost guaranteed crash + // as we're likely to be called by a paint event handler and so + // the assert is going to be triggered again and again and ... + continue; + } } //else: leave both the label and the bitmap invalid to draw a separator if ( !tool->IsControl() ) { - int tbStyle = 0; - if(HasFlag(wxTB_TEXT)) - { + int tbStyle = HasFlag(wxTB_VERTICAL) ? wxTB_VERTICAL : wxTB_HORIZONTAL; + if ( HasFlag(wxTB_TEXT) ) tbStyle |= wxTB_TEXT; - } - if(HasFlag(wxTB_VERTICAL)) - { - tbStyle |= wxTB_VERTICAL; - } - else - { - tbStyle |= wxTB_HORIZONTAL; - } - rend->DrawToolBarButton(dc, label, bitmap, rectTool, flags, tool->GetStyle(), tbStyle); + rend->DrawToolBarButton(dc, label, bitmap, rectTool, flags, + tool->GetStyle(), tbStyle); } else // control { -- 2.47.2