From 5a70051c7eba66e6c6d2fe5e5f6b6743f63c97d2 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Fri, 21 Aug 2020 08:43:50 -0700 Subject: [PATCH] Avoid assertion failure in wxButton with bitmap and empty label, see #18898 --- src/gtk/anybutton.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/gtk/anybutton.cpp b/src/gtk/anybutton.cpp index 9859016a37..8726432ddb 100644 --- a/src/gtk/anybutton.cpp +++ b/src/gtk/anybutton.cpp @@ -183,19 +183,13 @@ void wxAnyButton::GTKUpdateBitmap() void wxAnyButton::GTKDoShowBitmap(const wxBitmap& bitmap) { - wxASSERT_MSG( bitmap.IsOk(), "invalid bitmap" ); + wxCHECK_RET(bitmap.IsOk(), "invalid bitmap"); - GtkWidget *image; - if ( DontShowLabel() ) - { + GtkWidget* image = gtk_button_get_image(GTK_BUTTON(m_widget)); + if (image == NULL) image = gtk_bin_get_child(GTK_BIN(m_widget)); - } - else // have both label and bitmap - { - image = gtk_button_get_image(GTK_BUTTON(m_widget)); - } - wxCHECK_RET( image && GTK_IS_IMAGE(image), "must have image widget" ); + wxCHECK_RET(GTK_IS_IMAGE(image), "must have image widget"); gtk_image_set_from_pixbuf(GTK_IMAGE(image), bitmap.GetPixbuf()); }