Pārlūkot izejas kodu

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).
PatTheMav 3 gadi atpakaļ
vecāks
revīzija
e2db9b7f70
1 mainītis faili ar 6 papildinājumiem un 1 dzēšanām
  1. 6 1
      UI/window-basic-preview.cpp

+ 6 - 1
UI/window-basic-preview.cpp

@@ -2453,7 +2453,12 @@ void OBSBasicPreview::DrawSpacingHelpers()
 
 
 	OBSBasic *main = OBSBasic::Get();
 	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;
 		return;
 
 
 	OBSSceneItem item = main->GetCurrentSceneItem();
 	OBSSceneItem item = main->GetCurrentSceneItem();