summaryrefslogtreecommitdiff
path: root/vala/valalockstatement.vala
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2022-02-10 18:07:56 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2022-02-10 18:07:56 +0100
commitd9f702289b4b39683d0c9361e1ea02fd51ecae22 (patch)
tree7d51da4e32b82732c16495c7eef92ae1c3fd22ca /vala/valalockstatement.vala
parent8c5a6dca7c63f49f02165fb400c68f85790875ec (diff)
downloadvala-d9f702289b4b39683d0c9361e1ea02fd51ecae22.tar.gz
vala: Catch and throw possible inner error of lock statements
See 40c1dbfbfedb6c4a6b88df045eb1c2e7bdd38d93 Fixes https://gitlab.gnome.org/GNOME/vala/issues/83
Diffstat (limited to 'vala/valalockstatement.vala')
-rw-r--r--vala/valalockstatement.vala10
1 files changed, 9 insertions, 1 deletions
diff --git a/vala/valalockstatement.vala b/vala/valalockstatement.vala
index 65c579be6..1035e9efc 100644
--- a/vala/valalockstatement.vala
+++ b/vala/valalockstatement.vala
@@ -89,9 +89,17 @@ public class Vala.LockStatement : CodeNode, Statement {
var fin_body = new Block (source_reference);
fin_body.add_statement (new UnlockStatement (resource, source_reference));
+ var catch_body = new Block (source_reference);
+ catch_body.add_statement (new ThrowStatement (new ReferenceTransferExpression (new MemberAccess.simple ("_lock_error_")), source_reference));
+ var catch_clause = new CatchClause (new ErrorType (null, null), "_lock_error_", catch_body, source_reference);
+ catch_clause.error_type.value_owned = true;
+
+ var try_stmt = new TryStatement (body, fin_body, source_reference);
+ try_stmt.add_catch_clause (catch_clause);
+
var block = new Block (source_reference);
block.add_statement (new LockStatement (resource, null, source_reference));
- block.add_statement (new TryStatement (body, fin_body, source_reference));
+ block.add_statement (try_stmt);
var parent_block = (Block) parent_node;
parent_block.replace_statement (this, block);