From 6421ddb9b21d61306b59b220ceb32c14892839d9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 4 Nov 2019 22:54:42 +0100 Subject: [PATCH] Only use underline-rgba property with GTK > 3.16 This avoids glib warnings object class 'GtkTextTag' has no property named 'underline-rgba-set' when calling g_object_get() with older GTK and just avoids doing useless work. --- src/gtk/textctrl.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index eaad5c2809..675d597a42 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -1924,24 +1924,27 @@ bool wxTextCtrl::GetStyle(long position, wxTextAttr& style) wxColour underlineColour = wxNullColour; #ifdef __WXGTK3__ - GSList* tags = gtk_text_iter_get_tags(&positioni); - for ( GSList* tagp = tags; tagp != NULL; tagp = tagp->next ) + if ( wx_is_at_least_gtk3(16) ) { - GtkTextTag* tag = static_cast(tagp->data); - gboolean underlineSet = FALSE; - g_object_get(tag, "underline-rgba-set", &underlineSet, NULL); - if ( underlineSet ) + GSList* tags = gtk_text_iter_get_tags(&positioni); + for ( GSList* tagp = tags; tagp != NULL; tagp = tagp->next ) { - GdkRGBA* gdkColour = NULL; - g_object_get(tag, "underline-rgba", &gdkColour, NULL); - if ( gdkColour ) - underlineColour = wxColour(*gdkColour); - gdk_rgba_free(gdkColour); - break; + GtkTextTag* tag = static_cast(tagp->data); + gboolean underlineSet = FALSE; + g_object_get(tag, "underline-rgba-set", &underlineSet, NULL); + if ( underlineSet ) + { + GdkRGBA* gdkColour = NULL; + g_object_get(tag, "underline-rgba", &gdkColour, NULL); + if ( gdkColour ) + underlineColour = wxColour(*gdkColour); + gdk_rgba_free(gdkColour); + break; + } } + if ( tags ) + g_slist_free(tags); } - if ( tags ) - g_slist_free(tags); #endif if ( underlineType != wxTEXT_ATTR_UNDERLINE_NONE )