From b29bd6b44fdf18f6dcd789652dc2b05db8458b76 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 27 Nov 2011 19:49:54 +0000 Subject: [PATCH] Don't crash when changing label of label-less wxToggleButton in wxGTK. If a button doesn't show any text label, simply don't do anything when SetLabel() is called instead of replacing the image shown by the button with a text label as the button doesn't expect this to happen and doing it breaks its assumptions about the widgets it has and results in assert failures later. Closes #13693. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69830 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/tglbtn.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/gtk/tglbtn.cpp b/src/gtk/tglbtn.cpp index 4886ce1fcc..47a55a53af 100644 --- a/src/gtk/tglbtn.cpp +++ b/src/gtk/tglbtn.cpp @@ -166,6 +166,14 @@ void wxToggleButton::SetLabel(const wxString& label) wxAnyButton::SetLabel(label); + if ( HasFlag(wxBU_NOTEXT) ) + { + // Don't try to update the label for a button not showing it, this is + // unnecessary and can also actually replace the image we show with the + // label entirely breaking the button code, see #13693. + return; + } + const wxString labelGTK = GTKConvertMnemonics(label); gtk_button_set_label(GTK_BUTTON(m_widget), wxGTK_CONV(labelGTK)); @@ -184,10 +192,13 @@ bool wxToggleButton::DoSetLabelMarkup(const wxString& markup) wxControl::SetLabel(stripped); - GtkLabel * const label = GTKGetLabel(); - wxCHECK_MSG( label, false, "no label in this toggle button?" ); + if ( !HasFlag(wxBU_NOTEXT) ) + { + GtkLabel * const label = GTKGetLabel(); + wxCHECK_MSG( label, false, "no label in this toggle button?" ); - GTKSetLabelWithMarkupForLabel(label, markup); + GTKSetLabelWithMarkupForLabel(label, markup); + } return true; } -- 2.45.2