[libgdata] core: Fix handling early cancellation of batch operations



commit 3a3e1704e0da0c3ddeff973f1beb5c3a69d2b464
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sat Dec 11 18:24:09 2010 +0000

    core: Fix handling early cancellation of batch operations
    
    If we left cancellation handling to the GSimpleAsyncResult, our code to
    propagate errors to all the operation's callbacks was not being called if
    the GCancellable was cancelled really early in running the operation (e.g.
    before calling gdata_batch_operation_run[_async]()).
    
    This commit fixes the problem by disabling GSimpleAsyncResult's cancellation
    handling feature for batch operations.

 gdata/gdata-batch-operation.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/gdata/gdata-batch-operation.c b/gdata/gdata-batch-operation.c
index 21c4c1b..5492eb7 100644
--- a/gdata/gdata-batch-operation.c
+++ b/gdata/gdata-batch-operation.c
@@ -681,6 +681,11 @@ gdata_batch_operation_run_async (GDataBatchOperation *self, GCancellable *cancel
 	self->priv->is_async = TRUE;
 
 	result = g_simple_async_result_new (G_OBJECT (self), callback, user_data, gdata_batch_operation_run_async);
+
+	/* Disable handling of cancellation so that g_simple_async_result_run_in_thread() doesn't return immediately without calling run_thread() if
+	 * cancellable has already been cancelled by this point. */
+	g_simple_async_result_set_handle_cancellation (result, FALSE);
+
 	g_simple_async_result_run_in_thread (result, (GSimpleAsyncThreadFunc) run_thread, G_PRIORITY_DEFAULT, cancellable);
 	g_object_unref (result);
 }



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