From 753de748e5dd8c796d5eb2290adfc777bdae3501 Mon Sep 17 00:00:00 2001 From: Clayton Groeneveld Date: Sun, 7 Mar 2021 05:24:10 -0600 Subject: [PATCH] UI: Remove redundant code The UpdateSceneSelection function was doing the same thing as the code in the SetCurrentScene function. --- UI/window-basic-main-transitions.cpp | 2 -- UI/window-basic-main.cpp | 35 ++-------------------------- UI/window-basic-main.hpp | 2 -- 3 files changed, 2 insertions(+), 37 deletions(-) diff --git a/UI/window-basic-main-transitions.cpp b/UI/window-basic-main-transitions.cpp index 8b491a8cf..7709e1cd9 100644 --- a/UI/window-basic-main-transitions.cpp +++ b/UI/window-basic-main-transitions.cpp @@ -752,8 +752,6 @@ void OBSBasic::SetCurrentScene(OBSSource scene, bool force) } } - UpdateSceneSelection(scene); - if (scene) { bool userSwitched = (!force && !disableSaving); blog(LOG_INFO, "%s to scene '%s'", diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index 18061c4c1..2dab05f5d 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -2930,32 +2930,6 @@ void OBSBasic::AddSceneItem(OBSSceneItem item) } } -void OBSBasic::UpdateSceneSelection(OBSSource source) -{ - if (source) { - obs_scene_t *scene = obs_scene_from_source(source); - const char *name = obs_source_get_name(source); - - if (!scene) - return; - - QList items = - ui->scenes->findItems(QT_UTF8(name), Qt::MatchExactly); - - if (items.count()) { - sceneChanging = true; - ui->scenes->setCurrentItem(items.first()); - sceneChanging = false; - - OBSScene curScene = - GetOBSRef(ui->scenes->currentItem()); - if (api && scene != curScene) - api->on_event( - OBS_FRONTEND_EVENT_PREVIEW_SCENE_CHANGED); - } - } -} - static void RenameListValues(QListWidget *listWidget, const QString &newName, const QString &prevName) { @@ -4488,9 +4462,6 @@ void OBSBasic::on_scenes_currentItemChanged(QListWidgetItem *current, { obs_source_t *source = NULL; - if (sceneChanging) - return; - if (current) { obs_scene_t *scene; @@ -4730,18 +4701,16 @@ void OBSBasic::ChangeSceneIndex(bool relative, int offset, int invalidIdx) if (idx == -1 || idx == invalidIdx) return; - sceneChanging = true; - QListWidgetItem *item = ui->scenes->takeItem(idx); if (!relative) idx = 0; + ui->scenes->blockSignals(true); ui->scenes->insertItem(idx + offset, item); ui->scenes->setCurrentRow(idx + offset); item->setSelected(true); - - sceneChanging = false; + ui->scenes->blockSignals(false); OBSProjector::UpdateMultiviewProjectors(); } diff --git a/UI/window-basic-main.hpp b/UI/window-basic-main.hpp index ae03d1f59..6e6df73a8 100644 --- a/UI/window-basic-main.hpp +++ b/UI/window-basic-main.hpp @@ -235,8 +235,6 @@ private: gs_vertbuffer_t *boxBottom = nullptr; gs_vertbuffer_t *circle = nullptr; - bool sceneChanging = false; - int previewX = 0, previewY = 0; int previewCX = 0, previewCY = 0; float previewScale = 0.0f;