[vala/0.44] 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/0.44] codegen: Use available *_unref functions in G_DEFINE_AUTOPTR_CLEANUP_FUNC
- Date: Tue, 26 Mar 2019 07:08:15 +0000 (UTC)
commit 42ae3e95b77888036306e121df5e38c0cdab47aa
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 63ae8a153..3fa13b8f9 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -197,10 +197,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 382002584..07bd8e28f 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-variadic.test \
objects/constructors.vala \
objects/destructors.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]