diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2020-09-23 10:20:12 +0200 |
---|---|---|
committer | Mike Krus <mike.krus@kdab.com> | 2020-09-23 14:21:03 +0100 |
commit | 5a33b94b348e5c65155b526e7746d9fe45560959 (patch) | |
tree | 5ed9e0b61565b897fde485f52fa5087b6c231444 /src | |
parent | bfdeffa31df13ff0a21795c52c4a94a09f7706fc (diff) |
Add QNodePrivate::registerDestructionHelper for std::vector containers
Ideally should support generic containers but clang seems to fail to
generate the symbol on the mac.
Change-Id: Ic1d6d815ab9aff60a97b3b0047228f55d7efe158
Pick-to: 5.15
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/nodes/qnode_p.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/core/nodes/qnode_p.h b/src/core/nodes/qnode_p.h index 67d52cec7..9e8295156 100644 --- a/src/core/nodes/qnode_p.h +++ b/src/core/nodes/qnode_p.h @@ -54,6 +54,7 @@ #include <Qt3DCore/qnode.h> #include <functional> +#include <vector> #include <Qt3DCore/private/propertychangehandler_p.h> #include <Qt3DCore/private/qchangearbiter_p.h> @@ -133,6 +134,15 @@ public: m_destructionConnections.push_back({node, QObject::connect(node, &QNode::nodeDestroyed, f)}); } + template<typename Caller, typename NodeType> + void registerDestructionHelper(NodeType *node, DestructionFunctionPointer<Caller, NodeType> func, std::vector<NodeType*> &) + { + // If the node is destoyed, we make sure not to keep a dangling pointer to it + Q_Q(QNode); + auto f = [q, func, node]() { (static_cast<Caller *>(q)->*func)(node); }; + m_destructionConnections.push_back({node, QObject::connect(node, &QNode::nodeDestroyed, f)}); + } + template<typename Caller, typename ValueType> using DestructionFunctionValue = void (Caller::*)(const ValueType&); |