[vala/0.36] codegen: Unref GLib.AsyncResult on uncaught errors in coroutines



commit d242e8124e21294a97037f1091bc386f1c3e1dd1
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Fri Apr 28 15:31:19 2017 +0200

    codegen: Unref GLib.AsyncResult on uncaught errors in coroutines
    
    Ignoring the warning of uncaught error in async methods resulted in
    leaking a reference to the scopes GLib.AsyncResult.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=641171

 codegen/valagerrormodule.vala |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valagerrormodule.vala b/codegen/valagerrormodule.vala
index 041779b..47056f1 100644
--- a/codegen/valagerrormodule.vala
+++ b/codegen/valagerrormodule.vala
@@ -143,6 +143,10 @@ public class Vala.GErrorModule : CCodeDelegateModule {
                                ccode.add_return (new CCodeConstant ("NULL"));
                        }
                } else if (is_in_coroutine ()) {
+                       var async_result_expr = new CCodeMemberAccess.pointer (new CCodeIdentifier 
("_data_"), "_async_result");
+                       var unref = new CCodeFunctionCall (new CCodeIdentifier ("g_object_unref"));
+                       unref.add_argument (async_result_expr);
+                       ccode.add_expression (unref);
                        ccode.add_return (new CCodeConstant ("FALSE"));
                } else if (current_return_type != null) {
                        return_default_value (current_return_type);


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