From 25acf095ab99e10c5ab21609024857fd6d927d1e Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sat, 4 Jan 2014 19:26:15 -0700 Subject: [PATCH] Remove from list based upon data, not string - Added an extra comment regarding source removal - Made is so that when a scene item is removed from the sources list box, it removes the item based upon the GetClientData rather than by its string name. This is done because there may be duplicate sources in a particular scene, and it's important to remove the right one. --- obs/window-basic-main.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/obs/window-basic-main.cpp b/obs/window-basic-main.cpp index 216a6ecec..9e753a0c2 100644 --- a/obs/window-basic-main.cpp +++ b/obs/window-basic-main.cpp @@ -67,12 +67,15 @@ void OBSBasic::AddSceneItem(obs_sceneitem_t item) void OBSBasic::RemoveSceneItem(obs_sceneitem_t item) { - obs_source_t source = obs_sceneitem_getsource(item); - const char *name = obs_source_getname(source); + for (unsigned int idx = 0; idx < sources->GetCount(); idx++) { + obs_sceneitem_t curItem; + curItem = (obs_sceneitem_t)sources->GetClientData(idx); - int idx = sources->FindString(WX_UTF8(name)); - if (idx != wxNOT_FOUND) - sources->Delete(idx); + if (item == curItem) { + sources->Delete(idx); + break; + } + } } void OBSBasic::UpdateSources(obs_scene_t scene) @@ -456,6 +459,9 @@ void OBSBasic::sourceRemoveClicked(wxCommandEvent &event) obs_source_t source = obs_sceneitem_getsource(item); int ref = obs_sceneitem_destroy(item); + /* If this is the last reference in the scene, mark the source for + * removal. Reference count being at 1 means that it's no longer in + * any more scenes. */ if (ref == 1) obs_source_remove(source); }