From c54025b31c1fb02d325f6e78ccfb3f40504efced Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Wed, 23 Sep 2020 10:20:12 +0200 Subject: 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 Reviewed-by: Paul Lemire (cherry picked from commit 5a33b94b348e5c65155b526e7746d9fe45560959) --- src/core/nodes/qnode_p.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/core/nodes') diff --git a/src/core/nodes/qnode_p.h b/src/core/nodes/qnode_p.h index 5aa4c5328..ddea912f0 100644 --- a/src/core/nodes/qnode_p.h +++ b/src/core/nodes/qnode_p.h @@ -54,6 +54,7 @@ #include #include +#include #include #include @@ -139,6 +140,24 @@ public: m_destructionConnections.push_back({node, QObject::connect(node, &QNode::nodeDestroyed, f)}); } + template + void registerDestructionHelper(NodeType *node, DestructionFunctionPointer func, QList &) + { + // 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(q)->*func)(node); }; + m_destructionConnections.push_back({node, QObject::connect(node, &QNode::nodeDestroyed, f)}); + } + + template + void registerDestructionHelper(NodeType *node, DestructionFunctionPointer func, std::vector &) + { + // 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(q)->*func)(node); }; + m_destructionConnections.push_back({node, QObject::connect(node, &QNode::nodeDestroyed, f)}); + } + template using DestructionFunctionValue = void (Caller::*)(const ValueType&); -- cgit v1.2.3