UI: Fix possible race condition in DrawSpacingHelpers

The use of GetCurrentSceneItem can lead to a race condition between
the graphics thread (where this function will be run) and the main UI
thread, as both access the scene list model and iterate through its
members which can change during iteration (as there is no lock around
its access).
This commit is contained in:
PatTheMav
2023-08-14 18:09:05 +02:00
committed by Lain
parent fa9b7b042f
commit 8d82263513

View File

@@ -2461,10 +2461,10 @@ void OBSBasicPreview::DrawSpacingHelpers()
obs_scene_enum_items(main->GetCurrentScene(), FindSelected, &data);
if (data.sceneItems.size() > 1)
if (data.sceneItems.size() != 1)
return;
OBSSceneItem item = main->GetCurrentSceneItem();
OBSSceneItem item = data.sceneItems[0];
if (!item)
return;