diff --git a/app/node/graph.cpp b/app/node/graph.cpp index 52823d69d..f76f390b4 100644 --- a/app/node/graph.cpp +++ b/app/node/graph.cpp @@ -30,10 +30,17 @@ NodeGraph::NodeGraph() { } +NodeGraph::~NodeGraph() +{ + Clear(); +} + void NodeGraph::Clear() { + // By deleting the last nodes first, we assume that nodes that are most important are deleted last + // (e.g. Project's ColorManager or ProjectSettingsNode. while (!node_children_.isEmpty()) { - delete node_children_.first(); + delete node_children_.last(); } } diff --git a/app/node/graph.h b/app/node/graph.h index bb65bdb42..a49f21fcf 100644 --- a/app/node/graph.h +++ b/app/node/graph.h @@ -40,6 +40,11 @@ public: */ NodeGraph(); + /** + * @brief NodeGraph Destructor + */ + virtual ~NodeGraph() override; + /** * @brief Destructively destroys all nodes in the graph */