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:
jp9000 committed 2021-12-30 21:19:34 -08:00
1 parent 7f2dfd53a9
commit 52cc1d533e
3 files changed
+71 -75

No files matched your search

+4 -5
View File
@@ -403,9 +403,9 @@ void OBSBasic::TransitionToScene(OBSSource source, bool force,
OBSSource trOverride = GetOverrideTransition(source);
if (trOverride && !overridingTransition && !quickTransition) {
transition = trOverride;
transition = std::move(trOverride);
duration = GetOverrideTransitionDuration(source);
OverrideTransition(trOverride);
OverrideTransition(transition.Get());
overridingTransition = true;
}
@@ -974,7 +974,7 @@ void OBSBasic::TBarChanged(int value)
OverrideTransition(tBarTr);
overridingTransition = true;
transition = tBarTr;
transition = std::move(tBarTr);
}
obs_transition_set_manual_torque(transition, 8.0f, 0.05f);
@@ -1603,8 +1603,7 @@ void OBSBasic::SetPreviewProgramMode(bool enabled)
? OBS_SCENE_DUP_PRIVATE_COPY
: OBS_SCENE_DUP_PRIVATE_REFS);
} else {
dup = curScene;
obs_scene_addref(dup);
dup = std::move(OBSScene(curScene));
}
OBSSourceAutoRelease transition = obs_get_output_source(0);