From 4cf78b242130fedcc6e32d2afa724725eae24e53 Mon Sep 17 00:00:00 2001 From: mental Date: Sun, 1 Jul 2007 20:08:45 +0000 Subject: [PATCH] was trying to have my cake and eat it too, memory-management-wise ... for now, manual management for Subtree --- src/xml/subtree.cpp | 17 ++++------------- src/xml/subtree.h | 8 +++----- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/xml/subtree.cpp b/src/xml/subtree.cpp index 7c549e7d7..f19bf055a 100644 --- a/src/xml/subtree.cpp +++ b/src/xml/subtree.cpp @@ -32,25 +32,16 @@ void recursively(void (Node::*m)(NodeObserver &observer), } -Subtree::Subtree(Node &root) : _root(&root) { - recursively(&Node::addObserver, *_root, *this); +Subtree::Subtree(Node &root) : _root(root) { + recursively(&Node::addObserver, _root, *this); } Subtree::~Subtree() { - finish(); -} - -void Subtree::finish() { - if (_root) { - recursively(&Node::removeObserver, *_root, *this); - _root = NULL; - } + recursively(&Node::removeObserver, _root, *this); } void Subtree::synthesizeEvents(NodeObserver &observer) { - if (_root) { - recursively(&Node::synthesizeEvents, *_root, *this); - } + recursively(&Node::synthesizeEvents, _root, *this); } void Subtree::addObserver(NodeObserver &observer) { diff --git a/src/xml/subtree.h b/src/xml/subtree.h index 73a6485d1..a70598fca 100644 --- a/src/xml/subtree.h +++ b/src/xml/subtree.h @@ -17,22 +17,20 @@ #include "xml/node-observer.h" #include "xml/composite-node-observer.h" +#include "gc-finalized.h" namespace Inkscape { namespace XML { class Node; -class Subtree : public Inkscape::GC::Anchored, - public Inkscape::GC::Managed<>, +class Subtree : public GC::Managed, private NodeObserver { public: Subtree(Node &root); ~Subtree(); - void finish(); - void synthesizeEvents(NodeObserver &observer); void addObserver(NodeObserver &observer); void removeObserver(NodeObserver &observer); @@ -53,7 +51,7 @@ private: Util::ptr_shared old_value, Util::ptr_shared new_value); - Node *_root; + Node &_root; CompositeNodeObserver _observers; }; -- 2.30.2