Skip to content

lib/click: avoid reference loop in SingleDB, and make SingleDB internal

Click.SingleDB represents single DB directory, and is created and owned by Click.DB. As such, it cannot hold a strong reference to Click.DB that creates it, and will have to hold a weak reference.

However, since Click.SingleDB is a full GObject, it can theoretically outlive Click.DB. So, to be safe, use GLib.WeakRef instead of Vala's built-in weak keyword.

And while we're at it, also mark SingleDB's constructor as internal to avoid some weird thing to try to construct it.


The public -> internal change creates this diff in click.h:

--- lib/click/click.h.old       2023-04-12 18:59:29.938697595 +0000
+++ lib/click/click.h.new       2023-04-12 18:59:43.530905609 +0000
@@ -231,13 +231,6 @@
 gboolean click_installed_package_get_writeable (ClickInstalledPackage* self);
 GType click_single_db_get_type (void) G_GNUC_CONST;
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClickSingleDB, g_object_unref)
-GType click_db_get_type (void) G_GNUC_CONST;
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClickDB, g_object_unref)
-ClickSingleDB* click_single_db_new (const gchar* root,
-                                    ClickDB* master_db);
-ClickSingleDB* click_single_db_construct (GType object_type,
-                                          const gchar* root,
-                                          ClickDB* master_db);
 gchar* click_single_db_get_path (ClickSingleDB* self,
                                  const gchar* package,
                                  const gchar* version,
@@ -273,6 +266,8 @@
 void click_single_db_ensure_ownership (ClickSingleDB* self,
                                        GError** error);
 const gchar* click_single_db_get_root (ClickSingleDB* self);
+GType click_db_get_type (void) G_GNUC_CONST;
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClickDB, g_object_unref)
 ClickDB* click_db_new (void);
 ClickDB* click_db_construct (GType object_type);
 void click_db_read (ClickDB* self,

However, the symbol seems to still be in the libclick-0.4.so. @sunweaver, how should it be handled soname-wise, and does this creates any work for Debian?

Merge request reports