mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-04-13 11:10:31 -04:00
UI: Fix multithread-unsafe GetCurrentScene
The function `OBSBasic::GetCurrentScene()` is also called from the graphics thread and access to a QListWidget object, which is not multithread-safe.
This commit is contained in:
@@ -2769,8 +2769,7 @@ OBSSource OBSBasic::GetProgramSource()
|
||||
|
||||
OBSScene OBSBasic::GetCurrentScene()
|
||||
{
|
||||
QListWidgetItem *item = ui->scenes->currentItem();
|
||||
return item ? GetOBSRef<OBSScene>(item) : nullptr;
|
||||
return currentScene.load();
|
||||
}
|
||||
|
||||
OBSSceneItem OBSBasic::GetSceneItem(QListWidgetItem *item)
|
||||
@@ -3960,6 +3959,7 @@ void OBSBasic::RemoveSelectedScene()
|
||||
QListWidgetItem *item = ui->scenes->takeItem(curIndex);
|
||||
ui->scenes->insertItem(savedIndex, item);
|
||||
ui->scenes->setCurrentRow(savedIndex);
|
||||
currentScene = scene.Get();
|
||||
ui->scenes->blockSignals(false);
|
||||
};
|
||||
|
||||
@@ -4964,6 +4964,10 @@ void OBSBasic::on_scenes_currentItemChanged(QListWidgetItem *current,
|
||||
|
||||
scene = GetOBSRef<OBSScene>(current);
|
||||
source = obs_scene_get_source(scene);
|
||||
|
||||
currentScene = scene;
|
||||
} else {
|
||||
currentScene = NULL;
|
||||
}
|
||||
|
||||
SetCurrentScene(source);
|
||||
@@ -5227,6 +5231,7 @@ void OBSBasic::ChangeSceneIndex(bool relative, int offset, int invalidIdx)
|
||||
ui->scenes->insertItem(idx + offset, item);
|
||||
ui->scenes->setCurrentRow(idx + offset);
|
||||
item->setSelected(true);
|
||||
currentScene = GetOBSRef<OBSScene>(item).Get();
|
||||
ui->scenes->blockSignals(false);
|
||||
|
||||
OBSProjector::UpdateMultiviewProjectors();
|
||||
|
||||
Reference in New Issue
Block a user