[Xfce4-commits] <xfce4-power-manager:master> Don't leak when reload brightness information.
Ali Abdallah
noreply at xfce.org
Sat Jan 30 02:18:15 CET 2010
Updating branch refs/heads/master
to d27dce4bcf8e144dd5265b084e25ca4d0300b267 (commit)
from a830826ce72d043c7d6575ca110deb0e51ca9b2d (commit)
commit d27dce4bcf8e144dd5265b084e25ca4d0300b267
Author: Ali Abdallah <ali at ali-xfce.org>
Date: Fri Nov 6 18:34:38 2009 +0100
Don't leak when reload brightness information.
common/xfpm-brightness.c | 30 ++++++++++++++++++-------
panel-plugins/brightness/brightness-button.c | 1 +
2 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/common/xfpm-brightness.c b/common/xfpm-brightness.c
index ab2e024..b6f2a62 100644
--- a/common/xfpm-brightness.c
+++ b/common/xfpm-brightness.c
@@ -390,12 +390,15 @@ xfpm_brightness_setup_hal (XfpmBrightness *brightness)
HalDevice *device;
gchar **udi = NULL;
- brightness->priv->manager = hal_manager_new ();
+ if ( !brightness->priv->manager )
+ {
+ brightness->priv->manager = hal_manager_new ();
+
+ g_signal_connect (brightness->priv->manager, "connection-changed",
+ G_CALLBACK (xfpm_brightness_hal_connection_changed_cb), brightness);
+ }
brightness->priv->connected = hal_manager_get_is_connected (brightness->priv->manager);
-
- g_signal_connect (brightness->priv->manager, "connection-changed",
- G_CALLBACK (xfpm_brightness_hal_connection_changed_cb), brightness);
udi = hal_manager_find_device_by_capability (brightness->priv->manager, "laptop_panel");
@@ -472,12 +475,8 @@ xfpm_brightness_init (XfpmBrightness *brightness)
}
static void
-xfpm_brightness_finalize (GObject *object)
+xfpm_brightness_free_data (XfpmBrightness *brightness)
{
- XfpmBrightness *brightness;
-
- brightness = XFPM_BRIGHTNESS (object);
-
if ( brightness->priv->resource )
XRRFreeScreenResources (brightness->priv->resource);
@@ -487,7 +486,19 @@ xfpm_brightness_finalize (GObject *object)
if ( brightness->priv->hal_proxy )
g_object_unref (brightness->priv->hal_proxy);
+#endif
+}
+
+static void
+xfpm_brightness_finalize (GObject *object)
+{
+ XfpmBrightness *brightness;
+
+ brightness = XFPM_BRIGHTNESS (object);
+ xfpm_brightness_free_data (brightness);
+
+#ifdef WITH_HAL
if ( brightness->priv->manager )
g_object_unref (brightness->priv->manager);
#endif
@@ -506,6 +517,7 @@ xfpm_brightness_new (void)
gboolean
xfpm_brightness_setup (XfpmBrightness *brightness)
{
+ xfpm_brightness_free_data (brightness);
brightness->priv->xrandr_has_hw = xfpm_brightness_setup_xrandr (brightness);
if ( brightness->priv->xrandr_has_hw )
diff --git a/panel-plugins/brightness/brightness-button.c b/panel-plugins/brightness/brightness-button.c
index 8574ec9..b6e1893 100644
--- a/panel-plugins/brightness/brightness-button.c
+++ b/panel-plugins/brightness/brightness-button.c
@@ -590,6 +590,7 @@ reload_activated (GtkWidget *widget, BrightnessButton *button)
gint size;
destroy_popup (button);
+ xfpm_brightness_setup (button->priv->brightness);
brightness_button_create_popup (button);
brightness_button_set_tooltip (button);
More information about the Xfce4-commits
mailing list