From 33a24ec4c22522009f807386685bcee29c7d0647 Mon Sep 17 00:00:00 2001
From: g0dil <g0dil@wiback.org>
Date: Fri, 20 Feb 2009 23:22:41 +0000
Subject: [PATCH] Utils/Console: Reset GenericNode::parent_ when destroying
 parent

---
 Utils/Console/Node.cc | 8 ++++++++
 Utils/Console/Node.hh | 1 +
 2 files changed, 9 insertions(+)

diff --git a/Utils/Console/Node.cc b/Utils/Console/Node.cc
index 5096ba8ed..41c177971 100644
--- a/Utils/Console/Node.cc
+++ b/Utils/Console/Node.cc
@@ -102,6 +102,14 @@ prefix_ void senf::console::LinkNode::v_help(std::ostream & os)
 ///////////////////////////////////////////////////////////////////////////
 //senf::console::DirectoryNode
 
+prefix_ senf::console::DirectoryNode::~DirectoryNode()
+{
+    ChildMap::iterator i (children_.begin());
+    ChildMap::iterator const i_end (children_.end());
+    for (; i != i_end; ++i)
+        i->second->parent_ = 0;
+}
+
 prefix_ senf::console::GenericNode::ptr
 senf::console::DirectoryNode::remove(std::string const & name)
 {
diff --git a/Utils/Console/Node.hh b/Utils/Console/Node.hh
index 0367f5a87..fcd44d0d1 100644
--- a/Utils/Console/Node.hh
+++ b/Utils/Console/Node.hh
@@ -436,6 +436,7 @@ namespace console {
         static ptr create();            ///< Create node object.
                                         /**< You should normally use either mkdir() or
                                              ScopedDirectory instead of create() */
+        ~DirectoryNode();
 
         ///\}
         ///////////////////////////////////////////////////////////////////////////
-- 
GitLab