diff --git a/obs/window-basic-main.cpp b/obs/window-basic-main.cpp index 6f255d7cd4786204a9fd8d5aed01e0d0c13011a1..aa05e976cc4d995812e4429d2ee4a224b86d061c 100644 --- a/obs/window-basic-main.cpp +++ b/obs/window-basic-main.cpp @@ -60,11 +60,21 @@ using namespace std; +namespace { + +template +struct SignalContainer { + OBSRef ref; + vector> handlers; +}; + +} + Q_DECLARE_METATYPE(OBSScene); Q_DECLARE_METATYPE(OBSSceneItem); Q_DECLARE_METATYPE(OBSSource); Q_DECLARE_METATYPE(obs_order_movement); -Q_DECLARE_METATYPE(std::vector>); +Q_DECLARE_METATYPE(SignalContainer); template static T GetOBSRef(QListWidgetItem *item) @@ -1325,7 +1335,9 @@ void OBSBasic::AddScene(OBSSource source) signal_handler_t *handler = obs_source_get_signal_handler(source); - std::vector> handlers{ + SignalContainer container; + container.ref = scene; + container.handlers.assign({ std::make_shared(handler, "item_add", OBSBasic::SceneItemAdded, this), std::make_shared(handler, "item_remove", @@ -1336,10 +1348,10 @@ void OBSBasic::AddScene(OBSSource source) OBSBasic::SceneItemDeselected, this), std::make_shared(handler, "reorder", OBSBasic::SceneReordered, this), - }; + }); item->setData(static_cast(QtDataRole::OBSSignals), - QVariant::fromValue(handlers)); + QVariant::fromValue(container)); /* if the scene already has items (a duplicated scene) add them */ auto addSceneItem = [this] (obs_sceneitem_t *item)