[gvfs] daemon: Make progress callbacks work with try methods



commit e355526f0c6c00bbb7593d02accd4075c4da800f
Author: Ross Lagerwall <rosslagerwall gmail com>
Date:   Fri Nov 1 09:57:47 2013 +0200

    daemon: Make progress callbacks work with try methods
    
    Before, for each job type that implements progress callbacks, the
    progress_proxy was being unref'd immediately after the backend's try or
    run method had run.  This means that if the backend had an asynchronous
    callback which updated the progress, it wouldn't work because the
    progress_proxy had been removed.
    
    Fix this by unrefing the progress_proxy in the GVfsJobProgress class's
    finalize method.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=711247

 daemon/gvfsjobcopy.c     |    6 ------
 daemon/gvfsjobmove.c     |    6 ------
 daemon/gvfsjobprogress.c |    3 ++-
 daemon/gvfsjobpull.c     |    6 ------
 daemon/gvfsjobpush.c     |    6 ------
 5 files changed, 2 insertions(+), 25 deletions(-)
---
diff --git a/daemon/gvfsjobcopy.c b/daemon/gvfsjobcopy.c
index 78849f0..29132dd 100644
--- a/daemon/gvfsjobcopy.c
+++ b/daemon/gvfsjobcopy.c
@@ -131,9 +131,6 @@ run (GVfsJob *job)
               op_job->flags,
                progress_job->send_progress ? g_vfs_job_progress_callback : NULL,
                progress_job->send_progress ? job : NULL);
-  
-  if (progress_job->progress_proxy)
-    g_clear_object (&progress_job->progress_proxy);
 }
 
 static gboolean
@@ -156,9 +153,6 @@ try (GVfsJob *job)
                         op_job->flags,
                          progress_job->send_progress ? g_vfs_job_progress_callback : NULL,
                          progress_job->send_progress ? job : NULL);
-  
-  if (progress_job->progress_proxy)
-    g_clear_object (&progress_job->progress_proxy);
 
   return res;
 }
diff --git a/daemon/gvfsjobmove.c b/daemon/gvfsjobmove.c
index 0748055..d9c39a9 100644
--- a/daemon/gvfsjobmove.c
+++ b/daemon/gvfsjobmove.c
@@ -131,9 +131,6 @@ run (GVfsJob *job)
               op_job->flags,
                progress_job->send_progress ? g_vfs_job_progress_callback : NULL,
                progress_job->send_progress ? job : NULL);
-  
-  if (progress_job->progress_proxy)
-    g_clear_object (&progress_job->progress_proxy);
 }
 
 static gboolean
@@ -156,9 +153,6 @@ try (GVfsJob *job)
                         op_job->flags,
                         progress_job->send_progress ? g_vfs_job_progress_callback : NULL,
                         progress_job->send_progress ? job : NULL);
-  
-  if (progress_job->progress_proxy)
-    g_clear_object (&progress_job->progress_proxy);
 
   return res;
 }
diff --git a/daemon/gvfsjobprogress.c b/daemon/gvfsjobprogress.c
index e1ccc77..d6395df 100644
--- a/daemon/gvfsjobprogress.c
+++ b/daemon/gvfsjobprogress.c
@@ -41,6 +41,7 @@ g_vfs_job_progress_finalize (GObject *object)
   job = G_VFS_JOB_PROGRESS (object);
 
   g_free (job->callback_obj_path);
+  g_clear_object (&job->progress_proxy);
 
   if (G_OBJECT_CLASS (g_vfs_job_progress_parent_class)->finalize)
     (*G_OBJECT_CLASS (g_vfs_job_progress_parent_class)->finalize) (object);
@@ -88,7 +89,7 @@ g_vfs_job_progress_construct_proxy (GVfsJob *job)
   GVfsJobProgress *progress_job = G_VFS_JOB_PROGRESS (job);
   GError *error = NULL;
 
-  if (!progress_job->send_progress)
+  if (!progress_job->send_progress || progress_job->progress_proxy)
     return;
   
   progress_job->progress_proxy = gvfs_dbus_progress_proxy_new_sync (g_dbus_method_invocation_get_connection 
(dbus_job->invocation),
diff --git a/daemon/gvfsjobpull.c b/daemon/gvfsjobpull.c
index ffafedb..18b4007 100644
--- a/daemon/gvfsjobpull.c
+++ b/daemon/gvfsjobpull.c
@@ -136,9 +136,6 @@ run (GVfsJob *job)
                op_job->remove_source,
                progress_job->send_progress ? g_vfs_job_progress_callback : NULL,
                progress_job->send_progress ? job : NULL);
- 
-  if (progress_job->progress_proxy)
-    g_clear_object (&progress_job->progress_proxy);
 }
 
 static gboolean
@@ -162,9 +159,6 @@ try (GVfsJob *job)
                          op_job->remove_source,
                          progress_job->send_progress ? g_vfs_job_progress_callback : NULL,
                          progress_job->send_progress ? job : NULL);
-  
-  if (progress_job->progress_proxy)
-    g_clear_object (&progress_job->progress_proxy);
 
   return res;
 }
diff --git a/daemon/gvfsjobpush.c b/daemon/gvfsjobpush.c
index ddbec43..f074814 100644
--- a/daemon/gvfsjobpush.c
+++ b/daemon/gvfsjobpush.c
@@ -136,9 +136,6 @@ run (GVfsJob *job)
                op_job->remove_source,
                progress_job->send_progress ? g_vfs_job_progress_callback : NULL,
                progress_job->send_progress ? job : NULL);
-  
-  if (progress_job->progress_proxy)
-    g_clear_object (&progress_job->progress_proxy);
 }
 
 static gboolean
@@ -162,9 +159,6 @@ try (GVfsJob *job)
                          op_job->remove_source,
                          progress_job->send_progress ? g_vfs_job_progress_callback : NULL,
                          progress_job->send_progress ? job : NULL);
-  
-  if (progress_job->progress_proxy)
-    g_clear_object (&progress_job->progress_proxy);
 
   return res;
 }


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