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:
parent
7f2dfd53a9
commit
52cc1d533e
3 changed files with 71 additions and 75 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue