From 5ff328d21f5a7497257439cdd0266b81a54aa626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Pi=C3=B1eiro?= Date: Tue, 11 Sep 2012 21:17:22 +0200 Subject: [PATCH] a11y: Solved leak on gtk_widget_accessible_get_description https://bugzilla.gnome.org/show_bug.cgi?id=643611 --- gtk/a11y/gtkwidgetaccessible.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/gtk/a11y/gtkwidgetaccessible.c b/gtk/a11y/gtkwidgetaccessible.c index c386eb3ef9..b37232a510 100644 --- a/gtk/a11y/gtkwidgetaccessible.c +++ b/gtk/a11y/gtkwidgetaccessible.c @@ -24,6 +24,8 @@ #include "gtkwidgetaccessible.h" #include "gtknotebookpageaccessible.h" +#define TOOLTIP_KEY "tooltip" + extern GtkWidget *_focus_widget; @@ -106,6 +108,16 @@ gtk_widget_accessible_focus_event (AtkObject *obj, atk_object_notify_state_change (focus_obj, ATK_STATE_FOCUSED, focus_in); } +static void +gtk_widget_accessible_update_tooltip (GtkWidgetAccessible *accessible, + GtkWidget *widget) +{ + g_object_set_data_full (G_OBJECT (accessible), + TOOLTIP_KEY, + gtk_widget_get_tooltip_text (widget), + g_free); +} + static void gtk_widget_accessible_initialize (AtkObject *obj, gpointer data) @@ -123,6 +135,8 @@ gtk_widget_accessible_initialize (AtkObject *obj, GTK_WIDGET_ACCESSIBLE (obj)->layer = ATK_LAYER_WIDGET; obj->role = ATK_ROLE_UNKNOWN; + + gtk_widget_accessible_update_tooltip (GTK_WIDGET_ACCESSIBLE (obj), widget); } static const gchar * @@ -137,7 +151,7 @@ gtk_widget_accessible_get_description (AtkObject *accessible) if (accessible->description) return accessible->description; - return gtk_widget_get_tooltip_text (widget); + return g_object_get_data (G_OBJECT (accessible), TOOLTIP_KEY); } static AtkObject * @@ -475,7 +489,11 @@ gtk_widget_accessible_notify_gtk (GObject *obj, state = ATK_STATE_HORIZONTAL; value = (gtk_orientable_get_orientation (orientable) == GTK_ORIENTATION_HORIZONTAL); } - else + else if (g_strcmp0 (pspec->name, "tooltip-text") == 0) + { + gtk_widget_accessible_update_tooltip (GTK_WIDGET_ACCESSIBLE (atk_obj), + widget); + } return; atk_object_notify_state_change (atk_obj, state, value);