[vala/wip/gtask: 2/3] async: NULL check for cancelled GTasks
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc: 
- Subject: [vala/wip/gtask: 2/3] async: NULL check for cancelled GTasks
- Date: Sun,  2 Oct 2016 15:33:40 +0000 (UTC)
commit b4e7fdde115f9e4360c8c5c4368a73755bbb2623
Author: Ben Iofel <iofelben gmail com>
Date:   Wed Apr 27 18:35:02 2016 -0400
    async: NULL check for cancelled GTasks
    
    https://bugzilla.gnome.org/show_bug.cgi?id=763345
 codegen/valagasyncmodule.vala |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valagasyncmodule.vala b/codegen/valagasyncmodule.vala
index 99e17ff..527e1f5 100644
--- a/codegen/valagasyncmodule.vala
+++ b/codegen/valagasyncmodule.vala
@@ -570,7 +570,17 @@ public class Vala.GAsyncModule : GtkModule {
 
                        ccode.add_assignment (data_var, ccall);
 
-                       if (m.get_error_types ().size > 0) {
+                       bool has_cancellable = false;
+
+                       foreach (Parameter param in m.get_parameters ()) {
+                               if (param.variable_type is ObjectType && 
param.variable_type.data_type.get_full_name () == "GLib.Cancellable") {
+                                       has_cancellable = true;
+                                       break;
+                               }
+                       }
+
+                       // If a task is cancelled, g_task_propagate_pointer returns NULL
+                       if (m.get_error_types ().size > 0 || has_cancellable) {
                                var is_null = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, new 
CCodeConstant ("NULL"), data_var);
 
                                ccode.open_if (is_null);
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]