UI: Clean up sourceSceneRefs when removing scenes

Previously the sourceSceneRefs were being cleaned up in
OBSBasic::SceneItemRemoved; due to changes in
e82018579b the signal handler that called
OBSBasic::SceneItemRemoved is now being removed before the scene
triggers its item_remove signals
master
Palana 2015-07-07 02:02:41 +02:00
parent 9f2566fe69
commit 7bb430efd0
1 changed files with 19 additions and 0 deletions

View File

@ -1250,6 +1250,25 @@ void OBSBasic::RemoveScene(OBSSource source)
delete sel;
}
auto DeleteSceneRefs = [&](obs_sceneitem_t *si)
{
obs_source_t *source = obs_sceneitem_get_source(si);
sourceSceneRefs[source] -= 1;
if (!sourceSceneRefs[source]) {
obs_source_remove(source);
sourceSceneRefs.erase(source);
}
};
using DeleteSceneRefs_t = decltype(DeleteSceneRefs);
obs_scene_enum_items(obs_scene_from_source(source),
[](obs_scene_t *, obs_sceneitem_t *si, void *data)
{
(*static_cast<DeleteSceneRefs_t*>(data))(si);
return true;
}, static_cast<void*>(&DeleteSceneRefs));
SaveProject();
}