[vala/staging: 2/2] Clean up and fixes



commit 792f28636a87492b3fdda94d242e654cc523efb4
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Thu Dec 29 11:37:00 2016 +0100

    Clean up and fixes
    
    https://bugzilla.gnome.org/show_bug.cgi?id=744595

 codegen/valagdbusclientmodule.vala |   10 ++++---
 tests/dbus/rawvariants.test        |   47 +++++++++++++++--------------------
 2 files changed, 26 insertions(+), 31 deletions(-)
---
diff --git a/codegen/valagdbusclientmodule.vala b/codegen/valagdbusclientmodule.vala
index ad07baf..63f9097 100644
--- a/codegen/valagdbusclientmodule.vala
+++ b/codegen/valagdbusclientmodule.vala
@@ -1064,13 +1064,15 @@ public class Vala.GDBusClientModule : GDBusModule {
                                                ccode.add_assignment (new CCodeUnaryExpression 
(CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier ("result_length%d".printf (dim))), new 
CCodeIdentifier ("_result_length%d".printf (dim)));
                                        }
                                }
-
-                               unref_reply = new CCodeFunctionCall (new CCodeIdentifier ("g_variant_unref"));
-                               unref_reply.add_argument (new CCodeIdentifier ("_inner_reply"));
-                               ccode.add_expression (unref_reply);
                        }
                }
 
+               if (get_dbus_signature (prop) == null) {
+                       unref_reply = new CCodeFunctionCall (new CCodeIdentifier ("g_variant_unref"));
+                       unref_reply.add_argument (new CCodeIdentifier ("_inner_reply"));
+                       ccode.add_expression (unref_reply);
+               }
+
                if (prop.property_type.is_real_non_null_struct_type ()) {
                        ccode.add_return ();
                } else {
diff --git a/tests/dbus/rawvariants.test b/tests/dbus/rawvariants.test
index d05578c..ca80e74 100644
--- a/tests/dbus/rawvariants.test
+++ b/tests/dbus/rawvariants.test
@@ -26,53 +26,53 @@ public interface TestRaw : Object {
 void test_raw (TestRaw test) {
        var main_loop = new MainLoop ();
 
-       var id = test.test_signal.connect ( var_i => {
+       var id = test.test_signal.connect ((var_i) => {
                var i = (int) var_i;
-               warn_if_fail (i == 46);
+               assert (i == 46);
                main_loop.quit ();
        });
 
        int j = (int) test.test_method (23, 11);
-       warn_if_fail (j == 42);
+       assert (j == 42);
 
        main_loop.run ();
        test.disconnect (id);
 
        test.test_property = "hello";
        var s = (string) test.test_property;
-       warn_if_fail (s == "hello");
+       assert (s == "hello");
 }
 
 void test (Test test) {
        var main_loop = new MainLoop ();
 
-       var id = test.test_signal.connect ( i => {
-               warn_if_fail (i == 46);
+       var id = test.test_signal.connect ((i) => {
+               assert (i == 46);
                main_loop.quit ();
        });
 
        int j = test.test_method (23, 11);
-       warn_if_fail (j == 42);
+       assert (j == 42);
 
        main_loop.run ();
        test.disconnect (id);
 
        test.test_property = "hello";
        var s = test.test_property;
-       warn_if_fail (s == "hello");
+       assert (s == "hello");
 }
 
 void main () {
        // raw variant server, standard client
        Test test1 = Bus.get_proxy_sync (BusType.SESSION, "org.example.Test", "/org/example/testraw", 
DBusProxyFlags.DO_NOT_LOAD_PROPERTIES);
+       test (test1);
+
        // standard server, raw variant client
        TestRaw test2 = Bus.get_proxy_sync (BusType.SESSION, "org.example.Test", "/org/example/test", 
DBusProxyFlags.DO_NOT_LOAD_PROPERTIES);
+       test_raw (test2);
+
        // raw variant server, raw variant client
        TestRaw test3 = Bus.get_proxy_sync (BusType.SESSION, "org.example.Test", "/org/example/testraw", 
DBusProxyFlags.DO_NOT_LOAD_PROPERTIES);
-
-       test (test1);
-
-       test_raw (test2);
        test_raw (test3);
 }
 
@@ -80,14 +80,13 @@ Program: server
 
 [DBus (name = "org.example.Test")]
 public class Test : Object {
-       string _test;
-       public string test_property { owned get {return _test;} set { print("test_property = %s\n", value); 
_test = value; } }
+       public string test_property { owned get; set; }
 
        public signal void test_signal (int i);
 
        public int test_method (int j, int k) {
-               warn_if_fail (j == 23);
-               warn_if_fail (k == 11);
+               assert (j == 23);
+               assert (k == 11);
                test_signal (46);
                return 42;
        }
@@ -101,11 +100,9 @@ public class TestRaw : Object {
        public signal void test_signal ([DBus (signature = "i")] Variant i);
 
        [DBus (signature = "i")]
-       public Variant test_method ([DBus (signature = "i")] Variant var_j, [DBus (signature = "i")] Variant 
var_k) {
-               var j = (int) var_j;
-               var k = (int) var_k;
-               warn_if_fail (j == 23);
-               warn_if_fail (k == 11);
+       public Variant test_method ([DBus (signature = "i")] Variant j, [DBus (signature = "i")] Variant k) {
+               assert ((int) j == 23);
+               assert ((int) k == 11);
                test_signal (46);
                return 42;
        }
@@ -121,12 +118,8 @@ void client_exit (Pid pid, int status) {
 
 void main () {
        var conn = Bus.get_sync (BusType.SESSION);
-
-       var test = new Test ();
-       var testraw = new TestRaw ();
-
-       conn.register_object ("/org/example/test", test);
-       conn.register_object ("/org/example/testraw", testraw);
+       conn.register_object ("/org/example/test", new Test ());
+       conn.register_object ("/org/example/testraw", new TestRaw ());
 
        // try to register service in session bus
        var request_result = conn.call_sync ("org.freedesktop.DBus", "/org/freedesktop/DBus", 
"org.freedesktop.DBus", "RequestName",


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