[vala] codegen: Fix regression when capturing an unowned delegate variable
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Fix regression when capturing an unowned delegate variable
- Date: Mon, 9 May 2011 20:44:32 +0000 (UTC)
commit cbbf206f783b3d41dc9402dc4e6cc36a07b383fe
Author: Luca Bruno <lucabru src gnome org>
Date: Mon May 9 22:27:22 2011 +0200
codegen: Fix regression when capturing an unowned delegate variable
codegen/valaccodememberaccessmodule.vala | 12 +++++++++---
tests/asynchronous/closures.vala | 2 ++
2 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index a6ab4d6..38cb88d 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -364,7 +364,9 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
}
} else if (delegate_type != null && delegate_type.delegate_symbol.has_target) {
result.delegate_target_cvalue = new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (get_block_id (block))), get_delegate_target_cname (get_variable_cname (local.name)));
- result.delegate_target_destroy_notify_cvalue = new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (get_block_id (block))), get_delegate_target_destroy_notify_cname (get_variable_cname (local.name)));
+ if (delegate_type.value_owned) {
+ result.delegate_target_destroy_notify_cvalue = new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (get_block_id (block))), get_delegate_target_destroy_notify_cname (get_variable_cname (local.name)));
+ }
}
} else {
result.cvalue = get_variable_cexpression (local.name);
@@ -378,7 +380,9 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
} else if (delegate_type != null && delegate_type.delegate_symbol.has_target) {
if (is_in_coroutine ()) {
result.delegate_target_cvalue = new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), get_delegate_target_cname (get_variable_cname (local.name)));
- result.delegate_target_destroy_notify_cvalue = new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), get_delegate_target_destroy_notify_cname (get_variable_cname (local.name)));
+ if (local.variable_type.value_owned) {
+ result.delegate_target_destroy_notify_cvalue = new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), get_delegate_target_destroy_notify_cname (get_variable_cname (local.name)));
+ }
} else {
result.delegate_target_cvalue = new CCodeIdentifier (get_delegate_target_cname (get_variable_cname (local.name)));
if (local.variable_type.value_owned) {
@@ -444,7 +448,9 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
result.cvalue = get_variable_cexpression (param.name);
if (delegate_type != null && delegate_type.delegate_symbol.has_target) {
result.delegate_target_cvalue = new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), get_delegate_target_cname (get_variable_cname (param.name)));
- result.delegate_target_destroy_notify_cvalue = new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), get_delegate_target_destroy_notify_cname (get_variable_cname (param.name)));
+ if (delegate_type.value_owned) {
+ result.delegate_target_destroy_notify_cvalue = new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), get_delegate_target_destroy_notify_cname (get_variable_cname (param.name)));
+ }
}
} else {
var type_as_struct = result.value_type.data_type as Struct;
diff --git a/tests/asynchronous/closures.vala b/tests/asynchronous/closures.vala
index 791010c..3212481 100644
--- a/tests/asynchronous/closures.vala
+++ b/tests/asynchronous/closures.vala
@@ -3,8 +3,10 @@ delegate void Func ();
MainLoop main_loop;
async void foo (string baz) {
+ unowned SourceFunc func = null;
string bar = "hello";
Func foobar = () => {
+ func = null;
bar = baz;
};
foobar ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]