mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-03-02 13:27:14 -05:00
libobs, UI: Fix cpp auto-release assignment from OBSRefs
The *AutoRelease helpers should not take references from OBSRef objects. Instead, make an OBSRefAutoRelease base class, and OBSRef a subclass of that to allow moves, and then perform moves from those objects. This fixes an issue where *AutoRelease OBSRef objects would cause an unintended double release of objects after having been assigned values from non-*AutoRelease OBSRef objects.
This commit is contained in:
@@ -1012,9 +1012,7 @@ void OBSBasic::LoadData(obs_data_t *data, const char *file)
|
||||
LoadAudioDevice(AUX_AUDIO_4, 6, data);
|
||||
|
||||
if (!sources) {
|
||||
sources = groups;
|
||||
obs_data_array_addref(groups);
|
||||
groups = nullptr;
|
||||
sources = std::move(groups);
|
||||
} else {
|
||||
obs_data_array_push_back_array(sources, groups);
|
||||
}
|
||||
@@ -1059,12 +1057,10 @@ retryScene:
|
||||
goto retryScene;
|
||||
}
|
||||
|
||||
if (!curProgramScene) {
|
||||
curProgramScene = curScene;
|
||||
obs_source_addref(curScene);
|
||||
}
|
||||
|
||||
SetCurrentScene(curScene.Get(), true);
|
||||
|
||||
if (!curProgramScene)
|
||||
curProgramScene = std::move(curScene);
|
||||
if (IsPreviewProgramMode())
|
||||
TransitionToScene(curProgramScene.Get(), true);
|
||||
|
||||
@@ -5128,9 +5124,8 @@ void OBSBasic::on_actionAddScene_triggered()
|
||||
undo_fn, redo_fn, name, name);
|
||||
|
||||
OBSSceneAutoRelease scene = obs_scene_create(name.c_str());
|
||||
source = obs_scene_get_source(scene);
|
||||
obs_source_addref(source);
|
||||
SetCurrentScene(source.Get());
|
||||
obs_source_t *scene_source = obs_scene_get_source(scene);
|
||||
SetCurrentScene(scene_source);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user