From: Jürg Billeter Date: Thu, 4 Feb 2010 19:55:16 +0000 (+0100) Subject: Do not check unexpected errors if there is a general catch clause X-Git-Tag: 0.7.10~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7df672793c8305535c3f159af77041d9d64b801a;p=thirdparty%2Fvala.git Do not check unexpected errors if there is a general catch clause Fixes bug 608553. --- diff --git a/codegen/valagerrormodule.vala b/codegen/valagerrormodule.vala index 28d23e9a6..51c813285 100644 --- a/codegen/valagerrormodule.vala +++ b/codegen/valagerrormodule.vala @@ -209,6 +209,8 @@ internal class Vala.GErrorModule : CCodeDelegateModule { error_types.add (node_error_type); } + bool has_general_catch_clause = false; + if (!is_in_catch) { var handled_error_types = new ArrayList (); foreach (CatchClause clause in current_try.get_catch_clauses ()) { @@ -228,6 +230,7 @@ internal class Vala.GErrorModule : CCodeDelegateModule { if (clause.error_type.equals (gerror_type)) { // general catch clause, this should be the last one + has_general_catch_clause = true; cerror_block.add_statement (cgoto_stmt); break; } else { @@ -255,7 +258,11 @@ internal class Vala.GErrorModule : CCodeDelegateModule { } } - if (error_types.size > 0) { + if (has_general_catch_clause) { + // every possible error is already caught + // as there is a general catch clause + // no need to do anything else + } else if (error_types.size > 0) { // go to finally clause if no catch clause matches // and there are still unhandled error types cerror_block.add_statement (new CCodeGotoStatement ("__finally%d".printf (current_try_id)));