[vala/staging] Fix broken destruction of null-terminated arrays in async data structs
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] Fix broken destruction of null-terminated arrays in async data structs
- Date: Mon, 7 Nov 2016 13:50:01 +0000 (UTC)
commit 14cb50afc5e840d0f74f866571df2670d1a3958a
Author: Richard Wiedenhöft <richard wiedenhoeft xyz>
Date: Sun Feb 28 18:19:29 2016 +0100
Fix broken destruction of null-terminated arrays in async data structs
https://bugzilla.gnome.org/show_bug.cgi?id=762819
codegen/valagasyncmodule.vala | 12 +++++++++---
tests/Makefile.am | 1 +
tests/asynchronous/bug762819.vala | 22 ++++++++++++++++++++++
3 files changed, 32 insertions(+), 3 deletions(-)
---
diff --git a/codegen/valagasyncmodule.vala b/codegen/valagasyncmodule.vala
index 928e67b..0ab4336 100644
--- a/codegen/valagasyncmodule.vala
+++ b/codegen/valagasyncmodule.vala
@@ -123,9 +123,15 @@ public class Vala.GAsyncModule : GtkModule {
}
if (requires_destroy (m.return_type)) {
- /* this is very evil. */
- var v = new LocalVariable (m.return_type, ".result");
- ccode.add_expression (destroy_local (v));
+ if (get_ccode_array_length (m) || !(m.return_type is ArrayType)) {
+ /* this is very evil. */
+ var v = new LocalVariable (m.return_type, ".result");
+ ccode.add_expression (destroy_local (v));
+ } else {
+ var v = new GLibValue (m.return_type, new CCodeIdentifier ("_data_->result"),
true);
+ v.array_null_terminated = get_ccode_array_null_terminated (m);
+ ccode.add_expression (destroy_value (v));
+ }
}
if (m.binding == MemberBinding.INSTANCE) {
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 50d0e23..363dc29 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -222,6 +222,7 @@ TESTS = \
asynchronous/bug659886.vala \
asynchronous/bug661961.vala \
asynchronous/bug742621.vala \
+ asynchronous/bug762819.vala \
asynchronous/closures.vala \
asynchronous/generator.vala \
asynchronous/yield.vala \
diff --git a/tests/asynchronous/bug762819.vala b/tests/asynchronous/bug762819.vala
new file mode 100644
index 0000000..ea0f194
--- /dev/null
+++ b/tests/asynchronous/bug762819.vala
@@ -0,0 +1,22 @@
+abstract class Bar : GLib.Object {
+ [CCode (array_length = false, array_null_terminated = true)]
+ public abstract async string[] get_string_async ();
+}
+
+class Foo : Bar {
+ public override async string[] get_string_async () {
+ return { "foo", "bar" };
+ }
+}
+
+void main () {
+ var loop = new MainLoop ();
+ var foo = new Foo ();
+ foo.get_string_async.begin ((obj, res) => {
+ var result = foo.get_string_async.end (res);
+ assert (result.length == 2);
+ assert (result[1] == "bar");
+ loop.quit ();
+ });
+ loop.run ();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]