[vala/staging] codegen: Use available *_unref functions in G_DEFINE_AUTOPTR_CLEANUP_FUNC
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] codegen: Use available *_unref functions in G_DEFINE_AUTOPTR_CLEANUP_FUNC
- Date: Mon, 25 Mar 2019 20:15:50 +0000 (UTC)
commit 6d718504c77801fb8420130e0d83bf46549faed5
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Mon Mar 25 20:59:25 2019 +0100
codegen: Use available *_unref functions in G_DEFINE_AUTOPTR_CLEANUP_FUNC
Compact classes might have a unref_function in external packages. Therefore
subclassing them resulted in an errornous reference to free_function.
codegen/valagtypemodule.vala | 6 +++---
tests/Makefile.am | 1 +
tests/objects/compact-class-refcount.vala | 12 ++++++++++++
3 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index a8c98cdcf..6b0c3b310 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -196,10 +196,10 @@ public class Vala.GTypeModule : GErrorModule {
base_class = base_class.base_class;
}
string autoptr_cleanup_func;
- if (!is_gtypeinstance && !is_gsource) {
- autoptr_cleanup_func = get_ccode_free_function (base_class);
- } else {
+ if (is_reference_counting (base_class)) {
autoptr_cleanup_func = get_ccode_unref_function (base_class);
+ } else {
+ autoptr_cleanup_func = get_ccode_free_function (base_class);
}
if (autoptr_cleanup_func == null || autoptr_cleanup_func == "") {
Report.error (cl.source_reference, "internal error: autoptr_cleanup_func not
available");
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 72e09201b..abd7cb85c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -287,6 +287,7 @@ TESTS = \
objects/classes-implicit-implementation.vala \
objects/compact-class.vala \
objects/compact-class-destructor.vala \
+ objects/compact-class-refcount.vala \
objects/constructor-abstract-public.test \
objects/constructor-variadic.test \
objects/constructors.vala \
diff --git a/tests/objects/compact-class-refcount.vala b/tests/objects/compact-class-refcount.vala
new file mode 100644
index 000000000..1b8637e8b
--- /dev/null
+++ b/tests/objects/compact-class-refcount.vala
@@ -0,0 +1,12 @@
+class FooRegex : Regex {
+ public FooRegex () throws RegexError {
+ base ("^:*$");
+ }
+}
+
+void main () {
+ try {
+ var foo = new FooRegex ();
+ } catch {
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]