From 87ac4dc357e2d2fb7fd1c8ff06b1fa11f3810402 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 2 Dec 2019 00:12:45 +1100 Subject: [PATCH] Automatically disconnect all edges when a NodeParam is destroyed If a NodeParam is destroyed (presumably as the result of its parent Node being destroyed), any edge objects connecting to another param should be destroyed or else the edge will be floating referencing a now destroyed object. --- app/node/param.cpp | 8 ++++++++ app/node/param.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/app/node/param.cpp b/app/node/param.cpp index 9f9ce32a6..3bdc4e7b0 100644 --- a/app/node/param.cpp +++ b/app/node/param.cpp @@ -37,6 +37,14 @@ NodeParam::NodeParam(const QString &id) : Q_ASSERT(!id_.isEmpty()); } +NodeParam::~NodeParam() +{ + // Clear all connected edges + while (!edges_.isEmpty()) { + DisconnectEdge(edges_.last()); + } +} + const QString NodeParam::id() { return id_; diff --git a/app/node/param.h b/app/node/param.h index d037b6caa..8fc71d866 100644 --- a/app/node/param.h +++ b/app/node/param.h @@ -116,6 +116,8 @@ public: */ NodeParam(const QString& id); + virtual ~NodeParam() override; + /** * @brief Return ID of this parameter */