提交 9f6f6d63 编写于 作者: J jp9000

UI: Remove all unused user sources on load

This temporarily fixes an issue where potential (for whatever reason)
stray sources that aren't associated with any scenes could be saved and
then persist with the save data on load.
上级 49501be2
......@@ -415,6 +415,30 @@ void OBSBasic::LoadSceneListOrder(obs_data_array_t *array)
}
}
void OBSBasic::CleanupUnusedSources()
{
auto removeUnusedSources = [&](obs_source_t *source)
{
obs_scene_t *scene = obs_scene_from_source(source);
if (scene)
return;
if (sourceSceneRefs[source] == 0) {
sourceSceneRefs.erase(source);
obs_source_remove(source);
}
};
using func_type = decltype(removeUnusedSources);
obs_enum_sources(
[](void *f, obs_source_t *source)
{
(*static_cast<func_type*>(f))(source);
return true;
},
static_cast<void*>(&removeUnusedSources));
}
void OBSBasic::Load(const char *file)
{
if (!file) {
......@@ -478,6 +502,8 @@ void OBSBasic::Load(const char *file)
obs_data_release(data);
CleanupUnusedSources();
disableSaving--;
}
......
......@@ -163,6 +163,7 @@ private:
void CloseDialogs();
void ClearSceneData();
void CleanupUnusedSources();
void Nudge(int dist, MoveDir dir);
void OpenProjector(obs_source_t *source, int monitor);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册