From 4c7f0c0f2dde61da08cba7acc26cdfce15416d7f Mon Sep 17 00:00:00 2001 From: Juerg Billeter Date: Tue, 8 Jan 2008 17:49:49 +0000 Subject: [PATCH] fix memory management with simple conditional expressions, fixes bug 2008-01-08 Juerg Billeter * gobject/valaccodegenerator.vala: fix memory management with simple conditional expressions, fixes bug 501587 * tests/expressions-conditional.exp, tests/expressions-conditional.vala: test conditional expression with strings svn path=/trunk/; revision=809 --- ChangeLog | 8 ++++++++ gobject/valaccodegenerator.vala | 2 ++ tests/expressions-conditional.exp | 2 +- tests/expressions-conditional.vala | 16 ++++++++++++---- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 41d77d6..55bcfeb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2008-01-08 Jürg Billeter + * gobject/valaccodegenerator.vala: fix memory management with simple + conditional expressions, fixes bug 501587 + + * tests/expressions-conditional.exp, tests/expressions-conditional.vala: + test conditional expression with strings + +2008-01-08 Jürg Billeter + * vala/valainterfacewriter.vala, vala/valastruct.vala, vapigen/valagidlparser.vala: support simple_type attribute in metadata diff --git a/gobject/valaccodegenerator.vala b/gobject/valaccodegenerator.vala index 7672863..c5b1267 100644 --- a/gobject/valaccodegenerator.vala +++ b/gobject/valaccodegenerator.vala @@ -2665,6 +2665,8 @@ public class Vala.CCodeGenerator : CodeGenerator { public override void visit_conditional_expression (ConditionalExpression! expr) { expr.ccodenode = new CCodeConditionalExpression ((CCodeExpression) expr.condition.ccodenode, (CCodeExpression) expr.true_expression.ccodenode, (CCodeExpression) expr.false_expression.ccodenode); + + visit_expression (expr); } public override void visit_lambda_expression (LambdaExpression! l) { diff --git a/tests/expressions-conditional.exp b/tests/expressions-conditional.exp index f6fff3a..7224845 100644 --- a/tests/expressions-conditional.exp +++ b/tests/expressions-conditional.exp @@ -1 +1 @@ -Conditional Expression Test: 1 2 3 +Conditional Expression Test: 1 2 3 4 5 diff --git a/tests/expressions-conditional.vala b/tests/expressions-conditional.vala index 3129938..570b247 100644 --- a/tests/expressions-conditional.vala +++ b/tests/expressions-conditional.vala @@ -1,13 +1,21 @@ using GLib; class Maman.Bar : Object { + private static string get_number () { + return false ? "BAD" : "4"; + } + static int main (string[] args) { stdout.printf ("Conditional Expression Test: 1"); - + stdout.printf (" %d", false ? -1 : 2); - - stdout.printf (" 3\n"); - + + stdout.printf (" 3"); + + stdout.printf (" %s", get_number ()); + + stdout.printf (" 5\n"); + return 0; } } -- 2.7.4