mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-09-24 23:31:36 +08:00
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:
@@ -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--;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user