]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Fix line directives for ref_sink
authorJürg Billeter <j@bitron.ch>
Sat, 23 Jun 2012 14:23:23 +0000 (16:23 +0200)
committerJürg Billeter <j@bitron.ch>
Sat, 23 Jun 2012 14:25:11 +0000 (16:25 +0200)
Fixes bug 678237.

codegen/valaccodebasemodule.vala

index 769722a404558cc84e5563a7cb28b26c018802af..fd7fe1782975b4f1a0dcc45d429794c56808a68f 100644 (file)
@@ -5291,14 +5291,17 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        var sink_func = (cl != null) ? get_ccode_ref_sink_function (cl) : "";
 
                        if (sink_func != "") {
+                               if (type.nullable) {
+                                       var is_not_null = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, result.cvalue, new CCodeIdentifier ("NULL"));
+                                       ccode.open_if (is_not_null);
+                               }
+
                                var csink = new CCodeFunctionCall (new CCodeIdentifier (sink_func));
                                csink.add_argument (result.cvalue);
+                               ccode.add_expression (csink);
+
                                if (type.nullable) {
-                                       var is_not_null = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, result.cvalue, new CCodeIdentifier ("NULL"));
-                                       var csink_stat = new CCodeIfStatement (is_not_null, new CCodeExpressionStatement (csink));
-                                       ccode.add_statement (csink_stat);
-                               } else {
-                                       ccode.add_expression (csink);
+                                       ccode.close ();
                                }
                        } else {
                                Report.error (null, "type `%s' does not support floating references".printf (type.data_type.name));