[totem] Ref TotemScreensaver so it's still valid in the cb



commit 07e11de11a9f84209b31ebffdeec4983f91b9dae
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Aug 5 10:56:11 2010 +0100

    Ref TotemScreensaver so it's still valid in the cb
    
    Especially on exit, we need to keep our own reference of the
    screensaver object, or it might disappear by the time we
    receive the callback from GDBus.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=626092

 lib/totem-scrsaver.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/lib/totem-scrsaver.c b/lib/totem-scrsaver.c
index cbda040..7fb7307 100644
--- a/lib/totem-scrsaver.c
+++ b/lib/totem-scrsaver.c
@@ -115,6 +115,7 @@ on_inhibit_cb (GObject      *source_object,
 			g_warning ("Problem inhibiting the screensaver: %s", error->message);
 		}
 		g_error_free (error);
+		g_object_unref (scr);
 
 		return;
 	}
@@ -125,6 +126,8 @@ on_inhibit_cb (GObject      *source_object,
 	else
 		scr->priv->cookie = 0;
 	g_variant_unref (value);
+
+	g_object_unref (scr);
 }
 
 static void
@@ -155,6 +158,7 @@ on_uninhibit_cb (GObject      *source_object,
 			g_warning ("Problem uninhibiting the screensaver: %s", error->message);
 		}
 		g_error_free (error);
+		g_object_unref (scr);
 
 		return;
 	}
@@ -162,6 +166,8 @@ on_uninhibit_cb (GObject      *source_object,
 	/* clear the cookie */
 	scr->priv->cookie = 0;
 	g_variant_unref (value);
+
+	g_object_unref (scr);
 }
 
 static void
@@ -174,6 +180,7 @@ screensaver_inhibit_dbus (TotemScrsaver *scr,
                 return;
 
 	scr->priv->old_dbus_api = FALSE;
+	g_object_ref (scr);
 
 	if (inhibit) {
 		g_return_if_fail (scr->priv->reason != NULL);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]