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
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user