From 24091f9810c19808149e2004419ecd4cf7d6ff81 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 2 Dec 2019 00:14:33 +1100 Subject: [PATCH] explicitly destroy NodeParams in Node destructor NodeParams used to be destroyed automatically through the QObject system, but now that NodeParams perform actions that access the parent Node object in their destructor, the NodeParam destructor needs to be called before the Node has been fully destroyed. By destroying explicitly in the Node destructor we accomplish this. --- app/node/node.cpp | 14 ++++++++++++++ app/node/node.h | 10 ++++++++++ 2 files changed, 24 insertions(+) diff --git a/app/node/node.cpp b/app/node/node.cpp index 6ef47e2d8..7cdfbceb2 100644 --- a/app/node/node.cpp +++ b/app/node/node.cpp @@ -28,6 +28,15 @@ Node::Node() : { } +Node::~Node() +{ + // We delete in the Node destructor rather than relying on the QObject system because the parameter may need to + // perform actions on this Node object and we want them to be done before the Node object is fully destroyed + foreach (NodeParam* param, params_) { + delete param; + } +} + QString Node::Category() { // Return an empty category for any nodes that don't use one @@ -234,6 +243,11 @@ bool Node::IsBlock() return false; } +bool Node::IsTrack() +{ + return false; +} + rational Node::LastProcessedTime() { rational t; diff --git a/app/node/node.h b/app/node/node.h index d3deeeb8c..a02255ad4 100644 --- a/app/node/node.h +++ b/app/node/node.h @@ -51,6 +51,8 @@ class Node : public QObject public: Node(); + virtual ~Node() override; + /** * @brief Creates a clone of the Node * @@ -240,6 +242,14 @@ public: */ virtual bool IsBlock(); + /** + * @brief Returns whether this Node is a "Track" type or not + * + * You shouldn't ever need to override this since all derivatives of Track will automatically have this set to true. + * It's just a more convenient way of checking than dynamic_casting. + */ + virtual bool IsTrack(); + /** * @brief The main processing function *