[Xfce4-commits] [panel-plugins/xfce4-pulseaudio-plugin] 01/01: Fix some memory leaks and warnings

noreply at xfce.org noreply at xfce.org
Sun Mar 29 17:33:23 CEST 2020


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 a44d207f0d62a53a7842ed5a7e320018dc1ab6cd
Author: Sean Davis <smd.seandavis at gmail.com>
Date:   Sun Mar 29 11:33:17 2020 -0400

    Fix some memory leaks and warnings
---
 panel-plugin/pulseaudio-menu.c         | 48 +++++++++++++++++++---------------
 panel-plugin/pulseaudio-mpris-player.c |  9 ++++---
 panel-plugin/pulseaudio-mpris.c        |  6 +----
 3 files changed, 33 insertions(+), 30 deletions(-)

diff --git a/panel-plugin/pulseaudio-menu.c b/panel-plugin/pulseaudio-menu.c
index 1941759..9fb289a 100644
--- a/panel-plugin/pulseaudio-menu.c
+++ b/panel-plugin/pulseaudio-menu.c
@@ -301,27 +301,33 @@ pulseaudio_menu_volume_changed (PulseaudioMenu   *menu,
   g_return_if_fail (IS_PULSEAUDIO_MENU (menu));
   g_return_if_fail (IS_PULSEAUDIO_VOLUME (volume));
 
-  g_signal_handlers_block_by_func (G_OBJECT (menu->output_scale),
-                                   pulseaudio_menu_mute_output_item_toggled,
-                                   menu);
-  scale_menu_item_set_muted (SCALE_MENU_ITEM (menu->output_scale),
-                                  pulseaudio_volume_get_muted (volume));
-  g_signal_handlers_unblock_by_func (G_OBJECT (menu->output_scale),
-                                     pulseaudio_menu_mute_output_item_toggled,
-                                     menu);
-
-  scale_menu_item_set_value (SCALE_MENU_ITEM (menu->output_scale), pulseaudio_volume_get_volume (menu->volume) * 100.0);
-
-  g_signal_handlers_block_by_func (G_OBJECT (menu->input_scale),
-                                   pulseaudio_menu_mute_input_item_toggled,
-                                   menu);
-  scale_menu_item_set_muted (SCALE_MENU_ITEM (menu->input_scale),
-                                  pulseaudio_volume_get_muted_mic (volume));
-  g_signal_handlers_unblock_by_func (G_OBJECT (menu->input_scale),
-                                     pulseaudio_menu_mute_input_item_toggled,
-                                     menu);
-
-  scale_menu_item_set_value (SCALE_MENU_ITEM (menu->input_scale), pulseaudio_volume_get_volume_mic (menu->volume) * 100.0);
+  if (menu->output_scale != NULL)
+    {
+      g_signal_handlers_block_by_func (G_OBJECT (menu->output_scale),
+                                       pulseaudio_menu_mute_output_item_toggled,
+                                       menu);
+      scale_menu_item_set_muted (SCALE_MENU_ITEM (menu->output_scale),
+                                 pulseaudio_volume_get_muted (volume));
+      g_signal_handlers_unblock_by_func (G_OBJECT (menu->output_scale),
+                                         pulseaudio_menu_mute_output_item_toggled,
+                                         menu);
+      scale_menu_item_set_value (SCALE_MENU_ITEM (menu->output_scale),
+                                 pulseaudio_volume_get_volume (menu->volume) * 100.0);
+    }
+
+  if (menu->input_scale != NULL)
+    {
+      g_signal_handlers_block_by_func (G_OBJECT (menu->input_scale),
+                                       pulseaudio_menu_mute_input_item_toggled,
+                                       menu);
+      scale_menu_item_set_muted (SCALE_MENU_ITEM (menu->input_scale),
+                                 pulseaudio_volume_get_muted_mic (volume));
+      g_signal_handlers_unblock_by_func (G_OBJECT (menu->input_scale),
+                                         pulseaudio_menu_mute_input_item_toggled,
+                                         menu);
+      scale_menu_item_set_value (SCALE_MENU_ITEM (menu->input_scale),
+                                 pulseaudio_volume_get_volume_mic (menu->volume) * 100.0);
+    }
 }
 
 
diff --git a/panel-plugin/pulseaudio-mpris-player.c b/panel-plugin/pulseaudio-mpris-player.c
index 049fc06..dd2adfa 100644
--- a/panel-plugin/pulseaudio-mpris-player.c
+++ b/panel-plugin/pulseaudio-mpris-player.c
@@ -732,14 +732,13 @@ static gchar *
 find_desktop_entry (const gchar *player_name)
 {
   GKeyFile  *key_file;
-  gchar     *file;
+  gchar     *file = NULL;
   gchar     *filename = NULL;
-  gchar     *full_path;
 
   file = g_strconcat ("applications/", player_name, ".desktop", NULL);
 
   key_file = g_key_file_new();
-  if (g_key_file_load_from_data_dirs (key_file, file, &full_path, G_KEY_FILE_NONE, NULL))
+  if (g_key_file_load_from_data_dirs (key_file, file, NULL, G_KEY_FILE_NONE, NULL))
     {
       filename = g_strconcat (player_name, ".desktop", NULL);
     }
@@ -764,7 +763,9 @@ find_desktop_entry (const gchar *player_name)
     }
 
   g_key_file_free (key_file);
-  g_free (file);
+
+  if (file)
+    g_free (file);
 
   return filename;
 }
diff --git a/panel-plugin/pulseaudio-mpris.c b/panel-plugin/pulseaudio-mpris.c
index cb3b10b..881f04f 100644
--- a/panel-plugin/pulseaudio-mpris.c
+++ b/panel-plugin/pulseaudio-mpris.c
@@ -77,12 +77,11 @@ find_desktop_entry (const gchar *player_name)
   GKeyFile  *key_file;
   gchar     *file = NULL;
   gchar     *filename = NULL;
-  gchar     *full_path = NULL;
 
   file = g_strconcat ("applications/", player_name, ".desktop", NULL);
 
   key_file = g_key_file_new();
-  if (g_key_file_load_from_data_dirs (key_file, file, &full_path, G_KEY_FILE_NONE, NULL))
+  if (g_key_file_load_from_data_dirs (key_file, file, NULL, G_KEY_FILE_NONE, NULL))
     {
       filename = g_strconcat (player_name, ".desktop", NULL);
     }
@@ -111,9 +110,6 @@ find_desktop_entry (const gchar *player_name)
   if (file)
     g_free (file);
 
-  if (full_path)
-    g_free (full_path);
-
   return filename;
 }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list