[pango/prevent-mixed-linkage] Add a check for mixed linkage
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/prevent-mixed-linkage] Add a check for mixed linkage
- Date: Thu, 23 Jun 2022 13:36:07 +0000 (UTC)
commit 19992104201f198da7ce477410a606d7d0e4c7a5
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jun 23 09:31:06 2022 -0400
Add a check for mixed linkage
Having both pango 1.x and pango 2 linked into
the same process will cause trouble, because the
type and function names conflict.
Error out if we detect this situation.
pango/pango-context.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
---
diff --git a/pango/pango-context.c b/pango/pango-context.c
index d5e73cfe5..9c0b81c10 100644
--- a/pango/pango-context.c
+++ b/pango/pango-context.c
@@ -80,11 +80,33 @@ pango_context_init (PangoContext *context)
pango_font_description_set_size (context->font_desc, 12 * PANGO_SCALE);
}
+static gboolean
+pango_has_mixed_deps (void)
+{
+ GModule *module;
+ gpointer func;
+ gboolean result = FALSE;
+
+ module = g_module_open (NULL, 0);
+
+ if (g_module_symbol (module, "pango_hb_font_new", &func))
+ result = TRUE;
+
+ g_module_close (module);
+
+ return result;
+}
+
static void
pango_context_class_init (PangoContextClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ /* Put the check for mixed linkage here, for lack of a better place */
+ if (pango_has_mixed_deps ())
+ g_error ("Pango 2 symbols detected.\n"
+ "Using Pango 1.x and 2 in the same process is not supported.");
+
object_class->finalize = pango_context_finalize;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]