From 6c193435ccf7cce6c0992872586edf4867a667e5 Mon Sep 17 00:00:00 2001 From: Palana Date: Sat, 24 Oct 2015 16:07:05 +0200 Subject: [PATCH] UI: Move properties window creation for new sources Currently creating new sources can cause a deadlock: OBSBasicSourceSelect locks the scene mutex when adding a new source (required to add invisible sources), and later OBSBasic tries to lock the graphics mutex (via CreatePropertiesWindow); meanwhile the graphics thread is holding the graphics mutex and tries to lock each scene as it renders them, resulting in a (non-obvious from the code) lock ordering conflict. Moving the CreatePropertiesWindow call out of the locked scene mutex restores the previous lock ordering; in addition, the requirement for keeping sourceSceneRefs for opening that initial properties window is removed --- obs/window-basic-main.cpp | 8 ++------ obs/window-basic-source-select.cpp | 6 ++++-- obs/window-basic-source-select.hpp | 2 ++ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/obs/window-basic-main.cpp b/obs/window-basic-main.cpp index c41cd2e2..67a3c069 100644 --- a/obs/window-basic-main.cpp +++ b/obs/window-basic-main.cpp @@ -1266,8 +1266,6 @@ void OBSBasic::UpdateSources(OBSScene scene) void OBSBasic::InsertSceneItem(obs_sceneitem_t *item) { - obs_source_t *source = obs_sceneitem_get_source(item); - QListWidgetItem *listItem = new QListWidgetItem(); SetOBSRef(listItem, OBSSceneItem(item)); @@ -1275,10 +1273,6 @@ void OBSBasic::InsertSceneItem(obs_sceneitem_t *item) ui->sources->setCurrentRow(0, QItemSelectionModel::ClearAndSelect); SetupVisibilityItem(ui->sources, listItem, item); - - /* if the source was just created, open properties dialog */ - if (sourceSceneRefs[source] == 0 && loaded) - CreatePropertiesWindow(source); } void OBSBasic::CreateInteractionWindow(obs_source_t *source) @@ -2732,6 +2726,8 @@ void OBSBasic::AddSource(const char *id) if (id && *id) { OBSBasicSourceSelect sourceSelect(this, id); sourceSelect.exec(); + if (sourceSelect.newSource) + CreatePropertiesWindow(sourceSelect.newSource); } } diff --git a/obs/window-basic-source-select.cpp b/obs/window-basic-source-select.cpp index c433c5c9..fd9862ad 100644 --- a/obs/window-basic-source-select.cpp +++ b/obs/window-basic-source-select.cpp @@ -114,7 +114,7 @@ static void AddExisting(const char *name, const bool visible) } bool AddNew(QWidget *parent, const char *id, const char *name, - const bool visible) + const bool visible, OBSSource &newSource) { obs_source_t *source = obs_get_output_source(0); obs_scene_t *scene = obs_scene_from_source(source); @@ -140,6 +140,8 @@ bool AddNew(QWidget *parent, const char *id, const char *name, data.visible = visible; obs_scene_atomic_update(scene, AddSource, &data); + newSource = source; + success = true; } } @@ -170,7 +172,7 @@ void OBSBasicSourceSelect::on_buttonBox_accepted() } if (!AddNew(this, id, QT_TO_UTF8(ui->sourceName->text()), - visible)) + visible, newSource)) return; } diff --git a/obs/window-basic-source-select.hpp b/obs/window-basic-source-select.hpp index 49cbe429..bdfdc21e 100644 --- a/obs/window-basic-source-select.hpp +++ b/obs/window-basic-source-select.hpp @@ -45,4 +45,6 @@ private slots: public: OBSBasicSourceSelect(OBSBasic *parent, const char *id); + + OBSSource newSource; }; -- GitLab