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
This commit is contained in:
parent
d8991cbffe
commit
b29bd6b44f
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user