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.
This commit is contained in:
parent
49501be2a3
commit
9f6f6d632b
2 changed files with 27 additions and 0 deletions
|
|
@ -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--;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue