Browse Source

UI: Fix spamming of log when setting current scene

When setting the current scene and if it was the same as the previous,
the log would be spammed with switching scene messages.

This issue particularly happened when using undo/redo, as their
functions were setting the current scene.
Clayton Groeneveld 4 years ago
parent
commit
9ca7e1cb0f
1 changed files with 4 additions and 6 deletions
  1. 4 6
      UI/window-basic-main-transitions.cpp

+ 4 - 6
UI/window-basic-main-transitions.cpp

@@ -731,11 +731,10 @@ void OBSBasic::SetCurrentScene(OBSSource scene, bool force)
 				obs_source_inc_showing(scene);
 			if (actualLastScene)
 				obs_source_dec_showing(actualLastScene);
-			lastScene = OBSGetWeakRef(scene);
 		}
 	}
 
-	if (obs_scene_get_source(GetCurrentScene()) != scene) {
+	if (OBSGetStrongRef(lastScene) != scene) {
 		for (int i = 0; i < ui->scenes->count(); i++) {
 			QListWidgetItem *item = ui->scenes->item(i);
 			OBSScene itemScene = GetOBSRef<OBSScene>(item);
@@ -751,16 +750,16 @@ void OBSBasic::SetCurrentScene(OBSSource scene, bool force)
 				break;
 			}
 		}
-	}
 
-	UpdateContextBar(true);
+		lastScene = OBSGetWeakRef(scene);
 
-	if (scene) {
 		bool userSwitched = (!force && !disableSaving);
 		blog(LOG_INFO, "%s to scene '%s'",
 		     userSwitched ? "User switched" : "Switched",
 		     obs_source_get_name(scene));
 	}
+
+	UpdateContextBar(true);
 }
 
 void OBSBasic::CreateProgramDisplay()
@@ -1645,7 +1644,6 @@ void OBSBasic::SetPreviewProgramMode(bool enabled)
 			OBSSource actualLastScene = OBSGetStrongRef(lastScene);
 			if (actualLastScene)
 				obs_source_dec_showing(actualLastScene);
-			lastScene = nullptr;
 		}
 
 		programScene = nullptr;