Browse Source

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).
PatTheMav 2 years ago
parent
commit
8d82263513
1 changed files with 2 additions and 2 deletions
  1. 2 2
      UI/window-basic-preview.cpp

+ 2 - 2
UI/window-basic-preview.cpp

@@ -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;