]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Return a default value in delegate wrappers
authorLuca Bruno <lucabru@src.gnome.org>
Tue, 24 Feb 2015 12:47:12 +0000 (13:47 +0100)
committerLuca Bruno <lucabru@src.gnome.org>
Tue, 24 Feb 2015 15:51:36 +0000 (16:51 +0100)
Fixes bug 744639

codegen/valaccodedelegatemodule.vala

index 744f63a1d04e63d04158fd87217fc8064e5e9283..9eb57ed34ea3fc2c8a7e795bf861f9cee04bbfb6 100644 (file)
@@ -408,8 +408,13 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
                        ccall.add_argument (new CCodeConstant ("NULL"));
                        ccall.add_argument (new CCodeConstant ("NULL"));
                }
+
                if (m.return_type is VoidType || m.return_type.is_real_non_null_struct_type ()) {
                        ccode.add_expression (ccall);
+                       if (!(d.return_type is VoidType || d.return_type.is_real_non_null_struct_type ())) {
+                               // return a default value
+                               ccode.add_declaration (return_type_cname, new CCodeVariableDeclarator ("result", default_value_for_type (d.return_type, true)));
+                       }
                } else {
                        CCodeExpression result = ccall;
                        if (d.return_type is GenericType) {
@@ -435,7 +440,8 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
                        }
                }
 
-               if (!(m.return_type is VoidType || m.return_type.is_real_non_null_struct_type ())) {
+               if (!(m.return_type is VoidType || m.return_type.is_real_non_null_struct_type ()) ||
+                       !(d.return_type is VoidType || d.return_type.is_real_non_null_struct_type ())) {
                        ccode.add_return (new CCodeIdentifier ("result"));
                }