[vala/0.34] 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/0.34] Fix broken destruction of null-terminated arrays in async data structs
- Date: Wed, 1 Mar 2017 08:56:52 +0000 (UTC)
commit f554160c6f54b151e3bf0acc1b214a3a38c05da8
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 023d95e..487c990 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -204,6 +204,7 @@ TESTS = \
asynchronous/bug659886.vala \
asynchronous/bug661961.vala \
asynchronous/bug742621.vala \
+ asynchronous/bug762819.vala \
asynchronous/closures.vala \
dbus/basic-types.test \
dbus/arrays.test \
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]