浏览代码

UI: Fix redo recreating sources in the wrong scene

Fixes an issue where if creating a new source was re-done from a
different scene, the source would be created first in that scene and
then OBS would switch to the scene where the source originally was
created.
Changes the order of these two operations, which makes OBS create the
source in the correct scene.
gxalpha 4 年之前
父节点
当前提交
981e7f7079
共有 1 个文件被更改,包括 5 次插入5 次删除
  1. 5 5
      UI/window-basic-source-select.cpp

+ 5 - 5
UI/window-basic-source-select.cpp

@@ -269,6 +269,11 @@ void OBSBasicSourceSelect::on_buttonBox_accepted()
 		obs_data_set_bool(wrapper, "visible", visible);
 
 		auto redo = [scene_name, main](const std::string &data) {
+			obs_source_t *scene_source =
+				obs_get_source_by_name(scene_name.c_str());
+			main->SetCurrentScene(scene_source, true);
+			obs_source_release(scene_source);
+
 			obs_data_t *dat =
 				obs_data_create_from_json(data.c_str());
 			OBSSource source;
@@ -280,11 +285,6 @@ void OBSBasicSourceSelect::on_buttonBox_accepted()
 			obs_sceneitem_set_id(item, (int64_t)obs_data_get_int(
 							   dat, "item_id"));
 
-			obs_source_t *scene_source =
-				obs_get_source_by_name(scene_name.c_str());
-			main->SetCurrentScene(scene_source, true);
-			obs_source_release(scene_source);
-
 			main->RefreshSources(main->GetCurrentScene());
 			obs_data_release(dat);
 			obs_sceneitem_release(item);