mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
Extend the mixed-dependency check to modules as well
This helps prevent accidents with GTK_PATH.
This commit is contained in:
parent
bd0f159b6c
commit
64adba6e3e
@ -628,20 +628,30 @@ setlocale_initialization (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
/* Return TRUE if module_to_check causes version conflicts.
|
||||||
check_mixed_deps (void)
|
* If module_to_check is NULL, check the main module.
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
_gtk_module_has_mixed_deps (GModule *module_to_check)
|
||||||
{
|
{
|
||||||
GModule *module;
|
GModule *module;
|
||||||
gpointer func;
|
gpointer func;
|
||||||
|
gboolean result;
|
||||||
|
|
||||||
module = g_module_open (NULL, 0);
|
if (!module_to_check)
|
||||||
|
module = g_module_open (NULL, 0);
|
||||||
|
else
|
||||||
|
module = module_to_check;
|
||||||
|
|
||||||
if (g_module_symbol (module, "gtk_widget_device_is_shadowed", &func))
|
if (g_module_symbol (module, "gtk_widget_device_is_shadowed", &func))
|
||||||
{
|
result = TRUE;
|
||||||
g_error ("GTK+ 3 symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported");
|
else
|
||||||
}
|
result = FALSE;
|
||||||
|
|
||||||
g_module_close (module);
|
if (!module_to_check)
|
||||||
|
g_module_close (module);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -662,7 +672,8 @@ do_pre_parse_initialization (int *argc,
|
|||||||
|
|
||||||
pre_initialized = TRUE;
|
pre_initialized = TRUE;
|
||||||
|
|
||||||
check_mixed_deps ();
|
if (_gtk_module_has_mixed_deps (NULL))
|
||||||
|
g_error ("GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported");
|
||||||
|
|
||||||
gdk_pre_parse_libgtk_only ();
|
gdk_pre_parse_libgtk_only ();
|
||||||
gdk_event_handler_set ((GdkEventFunc)gtk_main_do_event, NULL, NULL);
|
gdk_event_handler_set ((GdkEventFunc)gtk_main_do_event, NULL, NULL);
|
||||||
|
@ -225,6 +225,9 @@ gboolean _gtk_boolean_handled_accumulator (GSignalInvocationHint *ihint,
|
|||||||
|
|
||||||
gchar *_gtk_get_lc_ctype (void);
|
gchar *_gtk_get_lc_ctype (void);
|
||||||
|
|
||||||
|
gboolean _gtk_module_has_mixed_deps (GModule *module);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GTK_MAIN_H__ */
|
#endif /* __GTK_MAIN_H__ */
|
||||||
|
@ -237,7 +237,16 @@ find_module (const gchar *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
module = g_module_open (module_name, G_MODULE_BIND_LOCAL | G_MODULE_BIND_LAZY);
|
module = g_module_open (module_name, G_MODULE_BIND_LOCAL | G_MODULE_BIND_LAZY);
|
||||||
g_free(module_name);
|
|
||||||
|
if (_gtk_module_has_mixed_deps (module))
|
||||||
|
{
|
||||||
|
g_warning ("GTK+ module %s cannot be loaded.\n"
|
||||||
|
"GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported.", module_name);
|
||||||
|
g_module_close (module);
|
||||||
|
module = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (module_name);
|
||||||
|
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
@ -354,8 +363,13 @@ load_module (GSList *module_list,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
g_message ("Failed to load module \"%s\": %s", name, g_module_error ());
|
{
|
||||||
|
const gchar *error = g_module_error ();
|
||||||
|
|
||||||
|
g_message ("Failed to load module \"%s\"%s%s",
|
||||||
|
name, error ? ": " : "", error ? error : "");
|
||||||
|
}
|
||||||
|
|
||||||
return module_list;
|
return module_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user