[Xfce4-commits] [panel-plugins/xfce4-pulseaudio-plugin] 01/01: Patch several memory leaks
noreply at xfce.org
noreply at xfce.org
Sun Dec 3 20:38:02 CET 2017
This is an automated email from the git hooks/post-receive script.
b l u e s a b r e p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository panel-plugins/xfce4-pulseaudio-plugin.
commit 6edbb3eaa9a988544727ebee8078f8a11607f380
Author: Sean Davis <smd.seandavis at gmail.com>
Date: Sun Dec 3 14:37:56 2017 -0500
Patch several memory leaks
---
panel-plugin/mprismenuitem.c | 1 -
panel-plugin/pulseaudio-config.c | 7 +++++-
panel-plugin/pulseaudio-menu.c | 3 +++
panel-plugin/pulseaudio-mpris-player.c | 43 +++++++++++++++++++++++-----------
panel-plugin/pulseaudio-mpris.c | 8 +++++++
panel-plugin/pulseaudio-plugin.c | 2 --
6 files changed, 46 insertions(+), 18 deletions(-)
diff --git a/panel-plugin/mprismenuitem.c b/panel-plugin/mprismenuitem.c
index fa454da..4af905e 100644
--- a/panel-plugin/mprismenuitem.c
+++ b/panel-plugin/mprismenuitem.c
@@ -173,7 +173,6 @@ mpris_menu_item_new_from_player_name (const gchar *player)
filename = find_desktop_entry (player);
if (filename == NULL)
{
- g_free (filename);
return NULL;
}
diff --git a/panel-plugin/pulseaudio-config.c b/panel-plugin/pulseaudio-config.c
index d44cf7c..5b54df5 100644
--- a/panel-plugin/pulseaudio-config.c
+++ b/panel-plugin/pulseaudio-config.c
@@ -549,6 +549,8 @@ pulseaudio_config_set_mpris_players (PulseaudioConfig *config,
g_value_set_static_string(&src, player_string);
pulseaudio_config_set_property (G_OBJECT (config), PROP_MPRIS_PLAYERS, &src, NULL);
+
+ g_free (player_string);
}
@@ -564,7 +566,10 @@ pulseaudio_config_add_mpris_player (PulseaudioConfig *config,
players = pulseaudio_config_get_mpris_players (config);
if (g_strv_contains ((const char * const *) players, player))
- return;
+ {
+ g_strfreev(players);
+ return;
+ }
players_string = g_strjoinv (";", players);
player_string = g_strjoin (";", players_string, player, NULL);
diff --git a/panel-plugin/pulseaudio-menu.c b/panel-plugin/pulseaudio-menu.c
index 7d1db15..b32a54d 100644
--- a/panel-plugin/pulseaudio-menu.c
+++ b/panel-plugin/pulseaudio-menu.c
@@ -556,6 +556,7 @@ pulseaudio_menu_new (PulseaudioVolume *volume,
gtk_widget_show(mi);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi);
}
+ g_list_free (sources);
/* MPRIS2 */
#ifdef HAVE_MPRIS2
@@ -651,6 +652,8 @@ pulseaudio_menu_new (PulseaudioVolume *volume,
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
}
}
+
+ g_strfreev (players);
}
}
#endif
diff --git a/panel-plugin/pulseaudio-mpris-player.c b/panel-plugin/pulseaudio-mpris-player.c
index fcf9202..4ba1037 100644
--- a/panel-plugin/pulseaudio-mpris-player.c
+++ b/panel-plugin/pulseaudio-mpris-player.c
@@ -147,6 +147,8 @@ pulseaudio_mpris_player_parse_metadata (PulseaudioMprisPlayer *player,
{
if (0 == g_ascii_strcasecmp (key, "xesam:title"))
{
+ if (player->title != NULL)
+ g_free (player->title);
player->title = g_strdup(g_variant_get_string(value, NULL));
}
else if (0 == g_ascii_strcasecmp (key, "xesam:artist"))
@@ -154,6 +156,9 @@ pulseaudio_mpris_player_parse_metadata (PulseaudioMprisPlayer *player,
artists = g_variant_dup_strv (value, NULL);
if (artists != NULL)
{
+ if (player->artist != NULL)
+ g_free(player->artist);
+
if (g_strv_length (artists) > 0)
{
player->artist = g_strdup (artists[0]);
@@ -162,6 +167,7 @@ pulseaudio_mpris_player_parse_metadata (PulseaudioMprisPlayer *player,
{
player->artist = g_strdup ("");
}
+
g_strfreev (artists);
}
}
@@ -603,19 +609,22 @@ static void
pulseaudio_mpris_player_set_details_from_desktop (PulseaudioMprisPlayer *player,
const gchar *player_name)
{
- GKeyFile *key_file;
- gchar *file;
- gchar *full_path;
- gchar *filename;
+ GKeyFile *key_file = NULL;
+ gchar *file = NULL;
+ gchar *full_path = NULL;
+ gchar *filename = NULL;
filename = find_desktop_entry (player_name);
+ if (player->player_label != NULL)
+ g_free (player->player_label);
+ if (player->icon_name != NULL)
+ g_free (player->icon_name);
+
if (filename == NULL)
{
- player->player_label = g_strdup(player->player);
- player->icon_name = "applications-multimedia";
-
- g_free (filename);
+ player->player_label = g_strdup (player->player);
+ player->icon_name = g_strdup ("applications-multimedia");
return;
}
@@ -628,18 +637,21 @@ pulseaudio_mpris_player_set_details_from_desktop (PulseaudioMprisPlayer *player,
gchar *name = g_key_file_get_string (key_file, "Desktop Entry", "Name", NULL);
gchar *icon_name = g_key_file_get_string (key_file, "Desktop Entry", "Icon", NULL);
- player->player_label = g_strdup(name);
- player->icon_name = g_strdup(icon_name);
+ player->player_label = g_strdup (name);
+ player->icon_name = g_strdup (icon_name);
g_free (name);
g_free (icon_name);
}
else
{
- player->player_label = g_strdup(player->player);
- player->icon_name = "applications-multimedia";
+ player->player_label = g_strdup (player->player);
+ player->icon_name = g_strdup ("applications-multimedia");
}
+ if (full_path != NULL)
+ g_free (full_path);
+
g_key_file_free (key_file);
g_free (file);
}
@@ -768,7 +780,7 @@ pulseaudio_mpris_player_dbus_connect (PulseaudioMprisPlayer *player)
g_error_free(gerror);
gerror = NULL;
}
- else
+ else
{
player->dbus_playlists_proxy = proxy;
}
@@ -944,7 +956,10 @@ pulseaudio_mpris_player_finalize (GObject *object)
player->watch_id = 0;
- (*G_OBJECT_CLASS (pulseaudio_mpris_player_parent_class)->finalize) (object);
+ if (player->playlists != NULL)
+ g_hash_table_destroy (player->playlists);
+
+ (*G_OBJECT_CLASS(pulseaudio_mpris_player_parent_class)->finalize)(object);
}
diff --git a/panel-plugin/pulseaudio-mpris.c b/panel-plugin/pulseaudio-mpris.c
index 5252d25..bebbcbe 100644
--- a/panel-plugin/pulseaudio-mpris.c
+++ b/panel-plugin/pulseaudio-mpris.c
@@ -196,6 +196,11 @@ pulseaudio_mpris_tick_cb (gpointer user_data)
}
}
+ /* TODO: Safely free this memory.
+ if (players != NULL)
+ g_strfreev (players);
+ */
+
return TRUE;
}
@@ -359,6 +364,9 @@ pulseaudio_mpris_finalize (GObject *object)
mpris->config = NULL;
mpris->dbus_connection = NULL;
+ if (mpris->players != NULL)
+ g_hash_table_destroy (mpris->players);
+
(*G_OBJECT_CLASS (pulseaudio_mpris_parent_class)->finalize) (object);
}
diff --git a/panel-plugin/pulseaudio-plugin.c b/panel-plugin/pulseaudio-plugin.c
index 9df3dd8..6879845 100644
--- a/panel-plugin/pulseaudio-plugin.c
+++ b/panel-plugin/pulseaudio-plugin.c
@@ -123,7 +123,6 @@ struct _PulseaudioPlugin
/* mpris */
PulseaudioMpris *mpris;
- gchar **players;
};
@@ -530,7 +529,6 @@ pulseaudio_plugin_construct (XfcePanelPlugin *plugin)
/* initialize mpris support */
#ifdef HAVE_MPRIS2
pulseaudio_plugin->mpris = pulseaudio_mpris_new (pulseaudio_plugin->config);
- pulseaudio_plugin->players = pulseaudio_mpris_get_available_players (pulseaudio_plugin->mpris);
#endif
/* instantiate a button box */
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list