Related to rhbz#927919
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/include/internal_libreport.h | 5 +++++
src/lib/glib_support.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
index 1d1d204..dbac2f7 100644
--- a/src/include/internal_libreport.h
+++ b/src/include/internal_libreport.h
@@ -281,6 +281,11 @@ bool is_in_comma_separated_list(const char *value, const char
*list);
#define is_in_comma_separated_list_of_glob_patterns
libreport_is_in_comma_separated_list_of_glob_patterns
bool is_in_comma_separated_list_of_glob_patterns(const char *value, const char *list);
+/* Calls GLib version appropriate initialization function.
+ */
+#define glib_init libreport_glib_init
+void glib_init(void);
+
/* Frees every element'd data using free(),
* then frees list itself using g_list_free(list):
*/
diff --git a/src/lib/glib_support.c b/src/lib/glib_support.c
index 1180537..fb97f4c 100644
--- a/src/lib/glib_support.c
+++ b/src/lib/glib_support.c
@@ -17,6 +17,38 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "internal_libreport.h"
+#include <glib-object.h>
+
+void glib_init(void)
+{
+#if (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 35)
+ /* Became deprecated in glib-2.35.1 (branch 2.36 commit
df02fa1e4cc61a2c7f3aafdf1a6534a831f1c0d6) */
+ g_type_init();
+#endif
+
+ /* This is not necessary but is IMO is good to know that:
+ *
+ * If want to be defensive and ensure we're linked to GObject
+ * call the following function [1]:
+ *
+ * g_type_ensure(G_TYPE_OBJECT);
+ *
+ *
+ * See glib README -> Notes about GLib 2.36, 1st paragraph
+ *
+ * 1:
https://bugzilla.gnome.org/show_bug.cgi?id=691077
+ */
+
+ /* Help with mysterious bug */
+ if (g_verbose > 0)
+ {
+ const gchar *version_mismatch = glib_check_version(GLIB_MAJOR_VERSION,
+ GLIB_MINOR_VERSION,
+ GLIB_MICRO_VERSION);
+ if (version_mismatch != NULL)
+ log("Running GLib incompatible version: %s", version_mismatch);
+ }
+}
void list_free_with_free(GList *list)
{
--
1.8.3.1