wpe: Make threaded view singleton creation thread safe

It was leading to interesting failures.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2165>
This commit is contained in:
Thibault Saunier 2021-04-15 13:28:42 -04:00
parent 41879b20c2
commit f9ce3946a1

View file

@ -66,9 +66,14 @@ static WPEContextThread *s_view = NULL;
WPEContextThread& WPEContextThread::singleton()
{
if (!s_view)
static gsize initialized = 0;
if (g_once_init_enter (&initialized)) {
s_view = new WPEContextThread;
g_once_init_leave (&initialized, 1);
}
return *s_view;
}