]> git.0d.be Git - empathy.git/commitdiff
Properly ref/unref the request table
authorCosimo Cecchi <cosimo.cecchi@collabora.co.uk>
Tue, 5 May 2009 13:02:23 +0000 (15:02 +0200)
committerCosimo Cecchi <cosimoc@gnome.org>
Mon, 1 Jun 2009 15:47:39 +0000 (17:47 +0200)
Destroy the request table early, and keep a reference when passing it to
the dispatcher.
Also, don't cancel the nonexistant EmpathyTpFile when stopping hashing.

libempathy/empathy-ft-handler.c

index ad497de4754a0425311d9b26449d8c275a6c1f7d..e5c18cbdb185cfc70d747afa31d6010a6e2b041f 100644 (file)
@@ -410,6 +410,10 @@ ft_handler_create_channel_cb (EmpathyDispatchOperation *operation,
 
   DEBUG ("Dispatcher create channel CB");
 
+  /* we can destroy now the request */
+  g_hash_table_destroy (priv->request);
+  priv->request = NULL;
+
   if (my_error == NULL)
     {
       g_cancellable_set_error_if_cancelled (priv->cancellable, &my_error);
@@ -447,8 +451,9 @@ ft_handler_push_to_dispatcher (EmpathyFTHandler *handler)
   dispatcher = empathy_dispatcher_dup_singleton ();
   account = empathy_contact_get_account (priv->contact);
 
-  empathy_dispatcher_create_channel (dispatcher, account, priv->request,
-      ft_handler_create_channel_cb, handler);
+  /* I want to own a reference to the request, and destroy it later */
+  empathy_dispatcher_create_channel (dispatcher, account,
+      g_hash_table_ref (priv->request), ft_handler_create_channel_cb, handler);
 
   g_object_unref (dispatcher);
 }
@@ -606,8 +611,6 @@ hash_job_async_read_cb (GObject *source,
   gssize bytes_read;
   GError *error = NULL;
 
-  DEBUG ("Reading a chunk for hashing.");
-
   bytes_read = g_input_stream_read_finish (hash_data->stream, res, &error);
   if (error != NULL)
     {
@@ -952,9 +955,13 @@ empathy_ft_handler_cancel_transfer (EmpathyFTHandler *handler)
 
   priv = GET_PRIV (handler);
 
-  g_return_if_fail (priv->tpfile != NULL);
-
-  empathy_tp_file_cancel (priv->tpfile);
+  /* if we don't have an EmpathyTpFile, we are hashing, so
+   * we can just cancel the GCancellable to stop it.
+   */
+  if (priv->tpfile == NULL)
+    g_cancellable_cancel (priv->cancellable);
+  else
+    empathy_tp_file_cancel (priv->tpfile);
 }
 
 void