gtk: Fail initialization of the sink if GTK4 is already initialized in the same process

Initializing GTK3 and GTK4 in the same process does not work and is not
supported.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6905>
This commit is contained in:
Sebastian Dröge 2024-05-21 17:49:33 +03:00 committed by Backport Bot
parent cdaf50de8f
commit 36a2eb0f03

View file

@ -203,6 +203,16 @@ gst_gtk_base_sink_get_widget (GstGtkBaseSink * gtk_sink)
if (gtk_sink->widget != NULL)
return g_object_ref (gtk_sink->widget);
/* Fix segfault when GTK3 and GTK4 are loaded (e.g. `gst-inspect-1.0 -a`)
* into the same process.
*
* GtkNoMediaFile only exists in GTK4 and is registered as part of
* gtk_init(). */
if (g_type_from_name ("GtkNoMediaFile")) {
GST_INFO_OBJECT (gtk_sink, "GTK4 is already initialized");
return NULL;
}
/* Ensure GTK is initialized, this has no side effect if it was already
* initialized. Also, we do that lazily, so the application can be first */
if (!gtk_init_check (NULL, NULL)) {