diff options
-rw-r--r-- | src/common/util/CountedPtr.h | 8 | ||||
-rw-r--r-- | src/libs/client/NodeModel.cpp | 1 | ||||
-rw-r--r-- | src/libs/client/ObjectModel.cpp | 4 | ||||
-rw-r--r-- | src/libs/client/ObjectModel.h | 2 | ||||
-rw-r--r-- | src/libs/client/PatchModel.cpp | 2 | ||||
-rw-r--r-- | src/libs/client/Store.cpp | 7 | ||||
-rw-r--r-- | src/progs/ingenuity/NodeController.cpp | 6 |
7 files changed, 21 insertions, 9 deletions
diff --git a/src/common/util/CountedPtr.h b/src/common/util/CountedPtr.h index 81604e45..d1a48a58 100644 --- a/src/common/util/CountedPtr.h +++ b/src/common/util/CountedPtr.h @@ -36,14 +36,14 @@ namespace boost { assert(std::find(counted_ptr_counters.begin(), counted_ptr_counters.end(), (void*)object) == counted_ptr_counters.end()); counted_ptr_counters.push_back(object); - //std::cerr << "Creating " << typeid(object).name() << " Pointer to " - //<< object << std::endl; + //std::cerr << "Creating CountedPtr to " + // << object << ", count = " << cnt << std::endl; } static void sp_scalar_destructor_hook(void* object, unsigned long cnt, void* ptr) { counted_ptr_counters.remove(object); - //std::cerr << "Destroying " << typeid(object).name() << " Pointer to " - //<< object << std::endl; + //std::cerr << "Destroying CountedPtr to " + // << object << ", count = " << cnt << std::endl; } } diff --git a/src/libs/client/NodeModel.cpp b/src/libs/client/NodeModel.cpp index 80f8f03a..8d9d8697 100644 --- a/src/libs/client/NodeModel.cpp +++ b/src/libs/client/NodeModel.cpp @@ -45,7 +45,6 @@ NodeModel::NodeModel(const string& plugin_uri, const Path& path) NodeModel::~NodeModel() { clear(); - m_controller.reset(); } diff --git a/src/libs/client/ObjectModel.cpp b/src/libs/client/ObjectModel.cpp index b8688585..4a0eca0d 100644 --- a/src/libs/client/ObjectModel.cpp +++ b/src/libs/client/ObjectModel.cpp @@ -25,6 +25,10 @@ ObjectModel::ObjectModel(const Path& path) { } +ObjectModel::~ObjectModel() +{ + m_controller.reset(); +} /** Get a piece of metadata for this objeect. * diff --git a/src/libs/client/ObjectModel.h b/src/libs/client/ObjectModel.h index 744d78a0..da3764d1 100644 --- a/src/libs/client/ObjectModel.h +++ b/src/libs/client/ObjectModel.h @@ -46,7 +46,7 @@ public: ObjectModel(const Path& path); ObjectModel() : m_path("/UNINITIALIZED") {} // FIXME: remove - virtual ~ObjectModel() {} + virtual ~ObjectModel(); const map<string, string>& metadata() const { return m_metadata; } string get_metadata(const string& key) const; diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp index 68a55b40..a65f1c49 100644 --- a/src/libs/client/PatchModel.cpp +++ b/src/libs/client/PatchModel.cpp @@ -129,6 +129,7 @@ PatchModel::remove_node(CountedPtr<NodeModel> nm) assert(i->second == nm); m_nodes.erase(i); removed_node_sig.emit(nm->path().name()); + i->second->parent().reset(); return; } @@ -146,6 +147,7 @@ PatchModel::remove_node(const string& name) //delete i->second; m_nodes.erase(i); removed_node_sig.emit(name); + i->second->parent().reset(); return; } diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp index c0bc1a31..df0bdd95 100644 --- a/src/libs/client/Store.cpp +++ b/src/libs/client/Store.cpp @@ -211,7 +211,12 @@ Store::add_plugin(CountedPtr<PluginModel> pm) void Store::destruction_event(const Path& path) { - remove_object(path); + CountedPtr<ObjectModel> removed = remove_object(path); + removed->controller().reset(); + cerr << "Store removed object " << path + << " controller count: " << removed->controller().use_count(); + removed.reset(); + cerr << ", model count: " << removed.use_count() << endl; } void diff --git a/src/progs/ingenuity/NodeController.cpp b/src/progs/ingenuity/NodeController.cpp index 641d975e..950f70c9 100644 --- a/src/progs/ingenuity/NodeController.cpp +++ b/src/progs/ingenuity/NodeController.cpp @@ -104,8 +104,10 @@ void NodeController::destroy() { cerr << "FIXME: NODE DESTROYED\n"; - destroy_module(); // cuts reference - //delete this; + destroy_module(); + CountedPtr<ObjectModel> model = m_model; + m_model->controller().reset(); + m_model.reset(); } |