From 5a18461fb84087b2d9b062733f7f833a5ab4cbd6 Mon Sep 17 00:00:00 2001 From: wangshaohui <97082645@qq.com> Date: Wed, 1 Jan 2025 09:07:27 +0800 Subject: [PATCH] UI: Fix wrong order for requesting mutex Below callstack is from graphic thread where gs_enter has been gotten. As this, the order of requesting mutex is as gs->sources_mutex. That is conflicting with basic logic in libobs. About basic request order, sources_mutex should be requested before gs. [callstask] render_displays (1)request gs enter DrawSpacingHelpers() CreateLabel obs_source_create_private (2)request obs->data.sources_mutex --- UI/window-basic-preview.cpp | 17 ++++++++++++++--- UI/window-basic-preview.hpp | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/UI/window-basic-preview.cpp b/UI/window-basic-preview.cpp index 361e318c2f360c..c5ee42966c0a0c 100644 --- a/UI/window-basic-preview.cpp +++ b/UI/window-basic-preview.cpp @@ -2488,9 +2488,20 @@ void OBSBasicPreview::DrawSpacingHelpers() vec3 start, end; float pixelRatio = main->GetDevicePixelRatio(); - for (int i = 0; i < 4; i++) { - if (!spacerLabel[i]) - spacerLabel[i] = CreateLabel(pixelRatio, i); + if (!labelCreated) { + QMetaObject::invokeMethod(this, [this, pixelRatio]() { + if (labelCreated) + return; + + for (int i = 0; i < 4; i++) { + if (!spacerLabel[i]) + spacerLabel[i] = CreateLabel(pixelRatio, i); + } + + labelCreated = true; + }); + + return; // wait label source to be created } vec3_set(&start, top.x, 0.0f, 1.0f); diff --git a/UI/window-basic-preview.hpp b/UI/window-basic-preview.hpp index e880a8dac9713a..6121cf755f64a7 100644 --- a/UI/window-basic-preview.hpp +++ b/UI/window-basic-preview.hpp @@ -188,6 +188,7 @@ private slots: static inline void operator delete(void *ptr) { bfree(ptr); } OBSSourceAutoRelease spacerLabel[4]; + bool labelCreated = false; int spacerPx[4] = {0}; void DrawSpacingHelpers();