From 00aeb5018e50a44eccf9ed910d7dde6d99c8cd1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= Date: Mon, 20 Jun 2022 15:35:54 -0400 Subject: [PATCH] gobject: Export gobject_init() function when doing static compilation When statically compiling GObject and another GObject based library into the same shared object, the constructors need to be called in the right order. This is the same as gobject_win32_init(), except that it's not specific to Windows. The same thing applies on other platforms. --- gobject/gtype.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gobject/gtype.c b/gobject/gtype.c index ded0acee28..190423dce5 100644 --- a/gobject/gtype.c +++ b/gobject/gtype.c @@ -4426,13 +4426,25 @@ g_type_init (void) g_assert_type_system_initialized (); } -static void +#ifdef GOBJECT_STATIC_COMPILATION +void gobject_init (void); + +#else +static +#endif +void gobject_init (void) { const gchar *env_string; GTypeInfo info; TypeNode *node; GType type G_GNUC_UNUSED /* when compiling with G_DISABLE_ASSERT */; + static gboolean gobject_inited = FALSE; + + if (gobject_inited) + return; + + gobject_inited = TRUE; /* Ensure GLib is initialized first, see * https://bugzilla.gnome.org/show_bug.cgi?id=756139 -- GitLab