From da73e3fc74352e3610f0f9509cc06290b5216221 Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 12 Jun 2006 17:57:01 +0000 Subject: [PATCH] Fixed engine-side node destruction bug git-svn-id: http://svn.drobilla.net/lad@34 a436a847-0d15-0410-975c-d299462d15a1 --- grauph/src/libs/client/PatchModel.cpp | 1 + grauph/src/libs/client/PatchModel.h | 1 + grauph/src/libs/engine/QueuedEngineInterface.cpp | 2 +- grauph/src/libs/engine/QueuedEvent.h | 2 +- grauph/src/libs/engine/events/DestroyEvent.cpp | 5 +++-- grauph/src/libs/engine/events/DestroyEvent.h | 2 +- grauph/src/progs/gtk/PatchController.cpp | 4 ++-- 7 files changed, 10 insertions(+), 7 deletions(-) diff --git a/grauph/src/libs/client/PatchModel.cpp b/grauph/src/libs/client/PatchModel.cpp index 90ffd38a..551b3d4c 100644 --- a/grauph/src/libs/client/PatchModel.cpp +++ b/grauph/src/libs/client/PatchModel.cpp @@ -80,6 +80,7 @@ PatchModel::remove_node(const string& name) if (i != m_nodes.end()) { //delete i->second; m_nodes.erase(i); + removed_node_sig.emit(name); return; } diff --git a/grauph/src/libs/client/PatchModel.h b/grauph/src/libs/client/PatchModel.h index bc794d25..6b3b212f 100644 --- a/grauph/src/libs/client/PatchModel.h +++ b/grauph/src/libs/client/PatchModel.h @@ -71,6 +71,7 @@ public: // Signals sigc::signal > new_node_sig; + sigc::signal removed_node_sig; sigc::signal > new_connection_sig; sigc::signal removed_connection_sig; diff --git a/grauph/src/libs/engine/QueuedEngineInterface.cpp b/grauph/src/libs/engine/QueuedEngineInterface.cpp index 0734eb7a..1b50deb9 100644 --- a/grauph/src/libs/engine/QueuedEngineInterface.cpp +++ b/grauph/src/libs/engine/QueuedEngineInterface.cpp @@ -149,7 +149,7 @@ QueuedEngineInterface::rename(const string& old_path, void QueuedEngineInterface::destroy(const string& path) { - DestroyEvent* ev = new DestroyEvent(_responder, path); + DestroyEvent* ev = new DestroyEvent(_responder, this, path); push(ev); } diff --git a/grauph/src/libs/engine/QueuedEvent.h b/grauph/src/libs/engine/QueuedEvent.h index 16560aaa..0cdaacdb 100644 --- a/grauph/src/libs/engine/QueuedEvent.h +++ b/grauph/src/libs/engine/QueuedEvent.h @@ -70,7 +70,7 @@ protected: : Event(responder), m_pre_processed(false), m_blocking(blocking), m_source(source) {} - // NULL event base (for internal events) + // NULL event base (for internal events only!) QueuedEvent() : Event(), m_pre_processed(false), m_blocking(false), m_source(NULL) {} diff --git a/grauph/src/libs/engine/events/DestroyEvent.cpp b/grauph/src/libs/engine/events/DestroyEvent.cpp index 3988195a..85ec0011 100644 --- a/grauph/src/libs/engine/events/DestroyEvent.cpp +++ b/grauph/src/libs/engine/events/DestroyEvent.cpp @@ -35,8 +35,8 @@ namespace Om { -DestroyEvent::DestroyEvent(CountedPtr responder, const string& path, bool lock_mutex) -: QueuedEvent(responder, true), +DestroyEvent::DestroyEvent(CountedPtr responder, QueuedEventSource* source, const string& path, bool lock_mutex) +: QueuedEvent(responder, true, source), m_path(path), m_node(NULL), m_patch_listnode(NULL), @@ -142,6 +142,7 @@ DestroyEvent::execute(samplecount offset) void DestroyEvent::post_process() { + assert(m_source); m_source->unblock(); if (m_node == NULL) { diff --git a/grauph/src/libs/engine/events/DestroyEvent.h b/grauph/src/libs/engine/events/DestroyEvent.h index fc579bf4..8ad5deba 100644 --- a/grauph/src/libs/engine/events/DestroyEvent.h +++ b/grauph/src/libs/engine/events/DestroyEvent.h @@ -44,7 +44,7 @@ class DisconnectPortEvent; class DestroyEvent : public QueuedEvent { public: - DestroyEvent(CountedPtr responder, const string& path, bool lock_mutex = true); + DestroyEvent(CountedPtr responder, QueuedEventSource* source, const string& path, bool lock_mutex = true); DestroyEvent(CountedPtr responder, Node* node, bool lock_mutex = true); ~DestroyEvent(); diff --git a/grauph/src/progs/gtk/PatchController.cpp b/grauph/src/progs/gtk/PatchController.cpp index 606cc65b..10f2f639 100644 --- a/grauph/src/progs/gtk/PatchController.cpp +++ b/grauph/src/progs/gtk/PatchController.cpp @@ -71,6 +71,7 @@ PatchController::PatchController(CountedPtr model) }*/ model->new_node_sig.connect(sigc::mem_fun(this, &PatchController::add_node)); + model->removed_node_sig.connect(sigc::mem_fun(this, &PatchController::remove_node)); model->new_connection_sig.connect(sigc::mem_fun(this, &PatchController::connection)); model->removed_connection_sig.connect(sigc::mem_fun(this, &PatchController::disconnection)); } @@ -483,6 +484,7 @@ void PatchController::remove_node(const string& name) { assert(name.find("/") == string::npos); + assert(!m_patch_model->get_node(name)); // Update breadcrumbs if necessary if (m_window != NULL) @@ -492,8 +494,6 @@ PatchController::remove_node(const string& name) assert(m_patch_view->canvas() != NULL); m_patch_view->canvas()->remove_module(name); } - - patch_model()->remove_node(name); }