diff --git a/UI/source-tree.cpp b/UI/source-tree.cpp index e6fad3670..369232a71 100644 --- a/UI/source-tree.cpp +++ b/UI/source-tree.cpp @@ -130,34 +130,35 @@ SourceTreeItem::SourceTreeItem(SourceTree *tree_, OBSSceneItem sceneitem_) /* --------------------------------------------------------- */ - auto setItemVisible = [this](bool checked) { + auto setItemVisible = [this](bool val) { obs_scene_t *scene = obs_sceneitem_get_scene(sceneitem); obs_source_t *scenesource = obs_scene_get_source(scene); int64_t id = obs_sceneitem_get_id(sceneitem); - std::string name = obs_source_get_name(scenesource); + const char *name = obs_source_get_name(scenesource); obs_source_t *source = obs_sceneitem_get_source(sceneitem); - auto undo_redo = [id, name](const std::string &val) { - bool vis = val[0] == '1'; + auto undo_redo = [](const std::string &name, int64_t id, + bool val) { obs_scene_t *s = obs_get_scene_by_name(name.c_str()); obs_sceneitem_t *si = obs_scene_find_sceneitem_by_id(s, id); if (si) - obs_sceneitem_set_visible(si, vis); + obs_sceneitem_set_visible(si, val); obs_scene_release(s); }; - QString str = QTStr(checked ? "Undo.ShowSceneItem" - : "Undo.HideSceneItem"); - str = str.arg(obs_source_get_name(source), name.c_str()); + QString str = QTStr(val ? "Undo.ShowSceneItem" + : "Undo.HideSceneItem"); OBSBasic *main = OBSBasic::Get(); - main->undo_s.add_action(str, undo_redo, undo_redo, - checked ? "0" : "1", - checked ? "1" : "0"); + main->undo_s.add_action( + str.arg(obs_source_get_name(source), name), + std::bind(undo_redo, std::placeholders::_1, id, !val), + std::bind(undo_redo, std::placeholders::_1, id, val), + name, name); SignalBlocker sourcesSignalBlocker(this); - obs_sceneitem_set_visible(sceneitem, checked); + obs_sceneitem_set_visible(sceneitem, val); }; auto setItemLocked = [this](bool checked) {