aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2011-11-08 22:59:16 +0100
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2011-11-08 22:59:16 +0100
commit108af6c38c4723a2d911cdb0c980d0b71140164b (patch)
treeea2a16441def1e90994878da33856b47bab5c4df /src
parent165dad49ccada35cdff74ae9692e9b5f6ec43a38 (diff)
downloadayatana-indicator-sound-108af6c38c4723a2d911cdb0c980d0b71140164b.tar.gz
ayatana-indicator-sound-108af6c38c4723a2d911cdb0c980d0b71140164b.tar.bz2
ayatana-indicator-sound-108af6c38c4723a2d911cdb0c980d0b71140164b.zip
Fix memory leak caused by updating the accessible description value
The accessible description string was duplicated every time that was updated, and never free'd. This commit fixes this.
Diffstat (limited to 'src')
-rw-r--r--src/indicator-sound.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index ee90647..8e2cb1a 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -54,6 +54,7 @@ struct _IndicatorSoundPrivate
GList* transport_widgets_list;
GDBusProxy *dbus_proxy;
SoundStateManager* state_manager;
+ gchar *cached_accessible_desc;
};
#define INDICATOR_SOUND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_SOUND_TYPE, IndicatorSoundPrivate))
@@ -154,6 +155,7 @@ indicator_sound_init (IndicatorSound *self)
GList* t_list = NULL;
priv->transport_widgets_list = t_list;
priv->state_manager = g_object_new (SOUND_TYPE_STATE_MANAGER, NULL);
+ priv->cached_accessible_desc = NULL;
g_signal_connect ( G_OBJECT(self->service),
INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE,
@@ -170,17 +172,23 @@ indicator_sound_dispose (GObject *object)
g_object_unref(G_OBJECT(self->service));
self->service = NULL;
}
- g_list_free ( priv->transport_widgets_list );
+ g_list_free (priv->transport_widgets_list);
G_OBJECT_CLASS (indicator_sound_parent_class)->dispose (object);
- return;
}
static void
indicator_sound_finalize (GObject *object)
{
+ IndicatorSound * self = INDICATOR_SOUND(object);
+ IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self);
+
+ if (priv->cached_accessible_desc) {
+ g_free (priv->cached_accessible_desc);
+ priv->cached_accessible_desc = NULL;
+ }
+
G_OBJECT_CLASS (indicator_sound_parent_class)->finalize (object);
- return;
}
static GtkLabel *
@@ -236,16 +244,19 @@ get_accessible_desc (IndicatorObject * io)
{
IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(io);
- if (priv->volume_widget != NULL){
- return g_strdup_printf(_("Volume (%'.0f%%)"), volume_widget_get_current_volume(priv->volume_widget));
+ if (priv->volume_widget != NULL) {
+ gchar *old_desc = priv->cached_accessible_desc;
+ priv->cached_accessible_desc = g_strdup_printf(_("Volume (%'.0f%%)"), volume_widget_get_current_volume (priv->volume_widget));
+ g_free (old_desc);
+ return priv->cached_accessible_desc;
}
return NULL;
}
-static const gchar * get_name_hint (IndicatorObject * io)
+static const gchar *get_name_hint (IndicatorObject * io)
{
- return "indicator-sound";
+ return PACKAGE_NAME;
}
static void