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.
This commit is contained in:
itsmattkc
2019-12-02 00:14:33 +11:00
parent 87ac4dc357
commit 24091f9810
2 changed files with 24 additions and 0 deletions
+14
View File
@@ -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;
+10
View File
@@ -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
*