Skip to content
Snippets Groups Projects
Commit 88d0e279 authored by Eric Koegel's avatar Eric Koegel
Browse files

Fix memory leaks, add sane defaults for panel icon

parent 87a4d728
No related branches found
No related tags found
No related merge requests found
......@@ -543,6 +543,7 @@ device_changed_cb (UpDevice *device, BatteryButton *button)
if ( type == UP_DEVICE_KIND_LINE_POWER )
{
/* Update the panel icon */
g_free(button->priv->panel_icon_name);
button->priv->panel_icon_name = icon_name;
battery_button_set_icon (button);
}
......@@ -599,6 +600,7 @@ battery_button_add_device (UpDevice *device, BatteryButton *button)
gtk_list_store_prepend (list_store, &iter);
/* Update the panel icon */
g_free(button->priv->panel_icon_name);
button->priv->panel_icon_name = icon_name;
battery_button_set_icon (button);
}
......@@ -613,9 +615,6 @@ battery_button_add_device (UpDevice *device, BatteryButton *button)
COL_OBJ_SIGNAL_ID, signal_id,
COL_OBJ_DEVICE_POINTER, device,
-1);
if ( pix )
g_object_unref (pix);
}
static void
......@@ -786,6 +785,8 @@ battery_button_init (BatteryButton *button)
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
button->priv->upower = up_client_new ();
button->priv->panel_icon_name = g_strdup(XFPM_AC_ADAPTER_ICON);
button->priv->panel_icon_width = 24;
g_signal_connect (button->priv->upower, "device-added", G_CALLBACK (device_added_cb), button);
g_signal_connect (button->priv->upower, "device-removed", G_CALLBACK (device_removed_cb), button);
......@@ -798,6 +799,8 @@ battery_button_finalize (GObject *object)
button = BATTERY_BUTTON (object);
g_free(button->priv->panel_icon_name);
g_signal_handlers_disconnect_by_data (button->priv->upower, button);
g_object_unref (button->priv->plugin);
......@@ -818,6 +821,8 @@ battery_button_set_icon (BatteryButton *button)
{
GdkPixbuf *pixbuf;
DBG("icon_width %d", button->priv->panel_icon_width);
pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
button->priv->panel_icon_name,
button->priv->panel_icon_width,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment