[vala/wip/transform: 132/140] GDBus: Handle fd_list being null



commit 4e3fd22533a15053b81cc10835380a03e838cbc1
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sun Mar 19 23:14:10 2017 +0100

    GDBus: Handle fd_list being null

 codegen/valagdbusclienttransformer.vala | 1 +
 codegen/valagdbusservertransformer.vala | 6 ++++++
 2 files changed, 7 insertions(+)
---
diff --git a/codegen/valagdbusclienttransformer.vala b/codegen/valagdbusclienttransformer.vala
index 2f006cfbe..81dec84d8 100644
--- a/codegen/valagdbusclienttransformer.vala
+++ b/codegen/valagdbusclienttransformer.vala
@@ -52,6 +52,7 @@ public class Vala.GDBusClientTransformer : GVariantTransformer {
                                fd_index = b.add_temp_declaration (null, expression ("0"));
                                statements (@"$fd_list = $message.get_unix_fd_list ();");
                        }
+                       statements (@"if ($fd_list == null) { throw new GLib.IOError.FAILED (\"FD List is 
NULL\"); }");
                        statements (@"$iter.next (\"h\", out $fd_index);");
                        if (type_name == "GLib.UnixInputStream") {
                                return expression (@"new GLib.UnixInputStream ($fd_list.get ($fd_index), 
true)");
diff --git a/codegen/valagdbusservertransformer.vala b/codegen/valagdbusservertransformer.vala
index ba03293c8..48a68e07e 100644
--- a/codegen/valagdbusservertransformer.vala
+++ b/codegen/valagdbusservertransformer.vala
@@ -64,6 +64,8 @@ public class Vala.GDBusServerTransformer : GDBusClientTransformer {
                        call = finish_call = (MethodCall) expression (@"object.$(m.name) ()");
                }
 
+               b.open_try ();
+
                var out_args = new string[0];
                var out_types = new DataType[0];
                string fd_list = null;
@@ -102,6 +104,10 @@ public class Vala.GDBusServerTransformer : GDBusClientTransformer {
                        }
                }
 
+               b.add_catch_all ("_invocation_gerror_");
+               statements ("invocation.return_gerror (_invocation_gerror_); return;");
+               b.close ();
+
                if (m.coroutine) {
                        call.add_argument (expression (@"(s, r) => $(ready.name) (s, r, invocation)"));
                        b.add_expression (call);


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