summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2019-11-03 16:34:47 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2019-11-03 16:55:52 +0100
commit8e908c01a0f2ba6863f130ea3a223af41b54eaab (patch)
tree70d1d47a3a4f857333216349c1b430d69fddeef1
parent7cb3a3f00dcbadded394a6cb9b7042b7d627bea8 (diff)
downloadvala-8e908c01a0f2ba6863f130ea3a223af41b54eaab.tar.gz
codegen: G_DEFINE_AUTOPTR_CLEANUP_FUNC must not declared more than once
Follow on f413cb32470d9c2598416772bc0166c6f974ec9f
-rw-r--r--codegen/valagtypemodule.vala6
1 files changed, 4 insertions, 2 deletions
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index bae49b2c5..51e69c3d7 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -197,7 +197,8 @@ public class Vala.GTypeModule : GErrorModule {
}
// Custom unref-methods need to be emitted before G_DEFINE_AUTOPTR_CLEANUP_FUNC,
// so we guard against that special case and handle it in generate_method_declaration.
- if (!(base_class.is_compact && is_reference_counting (base_class))) {
+ if (!(base_class.is_compact && is_reference_counting (base_class))
+ && (!context.use_header || decl_space.is_header)) {
string autoptr_cleanup_func;
if (is_reference_counting (base_class)) {
autoptr_cleanup_func = get_ccode_unref_function (base_class);
@@ -450,7 +451,8 @@ public class Vala.GTypeModule : GErrorModule {
// Custom unref-methods need to be emitted before G_DEFINE_AUTOPTR_CLEANUP_FUNC,
// in addition to the non-ref-countable case in generate_class_declaration.
unowned Class? cl = m.parent_symbol as Class;
- if (cl != null && cl.is_compact && get_ccode_unref_function (cl) == get_ccode_name (m)) {
+ if (cl != null && cl.is_compact && get_ccode_unref_function (cl) == get_ccode_name (m)
+ && (!context.use_header || decl_space.is_header)) {
decl_space.add_type_member_declaration (new CCodeIdentifier ("G_DEFINE_AUTOPTR_CLEANUP_FUNC (%s, %s)".printf (get_ccode_name (cl), get_ccode_name (m))));
decl_space.add_type_member_declaration (new CCodeNewline ());
}