Blob Blame History Raw
From 775211c190a01269aa731922f31b54b0451c7ce1 Mon Sep 17 00:00:00 2001
From: "Zeeshan Ali (Khattak)" <zeeshanak@gnome.org>
Date: Wed, 1 Apr 2015 18:24:32 +0100
Subject: [PATCH 5/7] service-client: Delay unrefing ServiceLocation

Lets try to ensure that apps are not still accessing the last location
before unrefing (and therefore destroying) it by delaying the unref
operation by 5 seconds after a ServiceLocation object becomes obsolete.

https://bugs.freedesktop.org/show_bug.cgi?id=89782
---
 src/gclue-service-client.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/gclue-service-client.c b/src/gclue-service-client.c
index 0ff3e85..ae22601 100644
--- a/src/gclue-service-client.c
+++ b/src/gclue-service-client.c
@@ -138,6 +138,14 @@ below_threshold (GClueServiceClient *client,
         return FALSE;
 }
 
+static gboolean
+on_prev_location_timeout (gpointer user_data)
+{
+        g_object_unref (user_data);
+
+        return FALSE;
+}
+
 static void
 on_locator_location_changed (GObject    *gobject,
                              GParamSpec *pspec,
@@ -163,7 +171,10 @@ on_locator_location_changed (GObject    *gobject,
                 return;
         }
 
-        g_clear_object (&priv->prev_location);
+        if (priv->prev_location != NULL)
+                // Lets try to ensure that apps are not still accessing the
+                // last location before unrefing (and therefore destroying) it.
+                g_timeout_add_seconds (5, on_prev_location_timeout, priv->prev_location);
         priv->prev_location = priv->location;
 
         path = next_location_path (client);
-- 
2.1.0