[gtk+] Avoid calling g_object_ref on NULL
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Avoid calling g_object_ref on NULL
- Date: Sat, 7 Mar 2015 22:52:21 +0000 (UTC)
commit 1f3328c096cf708d755fd6eb041b0e8663049ceb
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Mar 7 17:48:11 2015 -0500
Avoid calling g_object_ref on NULL
gtk_widget_set_visual() allows NULL for the visual, so be
careful ot to ref it unconditionally.
gtk/gtkwidget.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 715105d..d9c2a9c 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -11445,7 +11445,7 @@ gtk_widget_get_ancestor (GtkWidget *widget,
/**
* gtk_widget_set_visual:
* @widget: a #GtkWidget
- * @visual: visual to be used or %NULL to unset a previous one
+ * @visual: (allow-none): visual to be used or %NULL to unset a previous one
*
* Sets the visual that should be used for by widget and its children for
* creating #GdkWindows. The visual must be on the same #GdkScreen as
@@ -11461,14 +11461,13 @@ gtk_widget_set_visual (GtkWidget *widget,
{
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (visual == NULL || GDK_IS_VISUAL (visual));
+
if (visual)
- {
- g_return_if_fail (gtk_widget_get_screen (widget) == gdk_visual_get_screen (visual));
- }
+ g_return_if_fail (gtk_widget_get_screen (widget) == gdk_visual_get_screen (visual));
g_object_set_qdata_full (G_OBJECT (widget),
quark_visual,
- g_object_ref (visual),
+ visual ? g_object_ref (visual) : NULL,
g_object_unref);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]