From 66fd1b2e80a35592a6057d220183566d281a5d87 Mon Sep 17 00:00:00 2001 From: Palana Date: Sat, 27 Jun 2015 03:32:33 +0200 Subject: [PATCH] UI: Ignore sources selection self-update roundtrips --- obs/window-basic-main.cpp | 16 ++++++++++++++-- obs/window-basic-main.hpp | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/obs/window-basic-main.cpp b/obs/window-basic-main.cpp index 930c3c45e..5ed30a6cd 100644 --- a/obs/window-basic-main.cpp +++ b/obs/window-basic-main.cpp @@ -1206,7 +1206,7 @@ void OBSBasic::RenameSources(QString newName, QString prevName) void OBSBasic::SelectSceneItem(OBSScene scene, OBSSceneItem item, bool select) { - if (scene != GetCurrentScene()) + if (scene != GetCurrentScene() || ignoreSelectionUpdate) return; for (int i = 0; i < ui->sources->count(); i++) { @@ -2326,7 +2326,19 @@ void OBSBasic::on_sources_currentItemChanged(QListWidgetItem *current, if ((obs_source_get_output_flags(source) & OBS_SOURCE_VIDEO) == 0) return; - obs_scene_enum_items(GetCurrentScene(), select_one, &item); + auto IgnoreSelfUpdate = [&](obs_scene_t *scene) + { + ignoreSelectionUpdate = true; + obs_scene_enum_items(scene, select_one, &item); + ignoreSelectionUpdate = false; + }; + using IgnoreSelfUpdate_t = decltype(IgnoreSelfUpdate); + + obs_scene_atomic_update(GetCurrentScene(), + [](void *data, obs_scene_t *scene) + { + (*static_cast(data))(scene); + }, static_cast(&IgnoreSelfUpdate)); UNUSED_PARAMETER(prev); } diff --git a/obs/window-basic-main.hpp b/obs/window-basic-main.hpp index addec2743..20e2df402 100644 --- a/obs/window-basic-main.hpp +++ b/obs/window-basic-main.hpp @@ -96,6 +96,7 @@ private: gs_vertbuffer_t *circle = nullptr; bool sceneChanging = false; + bool ignoreSelectionUpdate = false; int previewX = 0, previewY = 0; int previewCX = 0, previewCY = 0;