From e2db9b7f70c7bec4a4cdc88631ea4a20fc58ffb7 Mon Sep 17 00:00:00 2001 From: PatTheMav Date: Tue, 11 Oct 2022 17:31:24 +0200 Subject: [PATCH] UI: Fix possible crash due to UI property access from graphics thread Selection state can change by main thread while UI thread (which calls DrawSpacingHelpers) tries to evaluate the amount of selected items. Get amount of selected items by enumerating over the scene data instead (which stays within the graphics thread). --- UI/window-basic-preview.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/UI/window-basic-preview.cpp b/UI/window-basic-preview.cpp index df3a2a610..c0d18e724 100644 --- a/UI/window-basic-preview.cpp +++ b/UI/window-basic-preview.cpp @@ -2453,7 +2453,12 @@ void OBSBasicPreview::DrawSpacingHelpers() OBSBasic *main = OBSBasic::Get(); - if (main->ui->sources->selectionModel()->selectedIndexes().count() > 1) + vec2 s; + SceneFindBoxData data(s, s); + + obs_scene_enum_items(main->GetCurrentScene(), FindSelected, &data); + + if (data.sceneItems.size() > 1) return; OBSSceneItem item = main->GetCurrentSceneItem();