summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/common/util/CountedPtr.h13
-rw-r--r--src/progs/gtk/NodeController.cpp1
-rw-r--r--src/progs/gtk/PatchController.cpp95
-rw-r--r--src/progs/gtk/PatchController.h4
4 files changed, 55 insertions, 58 deletions
diff --git a/src/common/util/CountedPtr.h b/src/common/util/CountedPtr.h
index 0886bf36..10c724c5 100644
--- a/src/common/util/CountedPtr.h
+++ b/src/common/util/CountedPtr.h
@@ -86,15 +86,16 @@ public:
// Fail if this is not a valid cast
if (y) {
#ifdef WITH_RTTI
- T* const unused_variable = dynamic_cast<T* const>(y._counter->ptr);
+ T* const casted_y = dynamic_cast<T* const>(y._counter->ptr);
#else
- T* const unused_variable = static_cast<T* const>(y._counter->ptr);
+ T* const casted_y = static_cast<T* const>(y._counter->ptr);
#endif
- assert(unused_variable == y._counter->ptr); // shuts up gcc
+ if (casted_y != NULL) {
+ assert(casted_y == y._counter->ptr);
+ //release(); // FIXME: leak?
+ retain((Counter*)y._counter);
+ }
}
-
- //release();
- retain((Counter*)y._counter);
}
/** Assign to the value of a CountedPtr of the same type. */
diff --git a/src/progs/gtk/NodeController.cpp b/src/progs/gtk/NodeController.cpp
index 6cc0b94e..b73da18b 100644
--- a/src/progs/gtk/NodeController.cpp
+++ b/src/progs/gtk/NodeController.cpp
@@ -187,6 +187,7 @@ NodeController::metadata_update(const string& key, const string& value)
if (m_bridge_port != NULL)
m_bridge_port->metadata_update(key, value);
+
GtkObjectController::metadata_update(key, value);
}
diff --git a/src/progs/gtk/PatchController.cpp b/src/progs/gtk/PatchController.cpp
index cbc8f626..8246efa6 100644
--- a/src/progs/gtk/PatchController.cpp
+++ b/src/progs/gtk/PatchController.cpp
@@ -292,7 +292,6 @@ PatchController::create_module(OmFlowCanvas* canvas)
create_all_ports();
m_module->move_to(node_model()->x(), node_model()->y());
- m_module->store_location();
}
@@ -388,93 +387,91 @@ PatchController::create_connection(CountedPtr<ConnectionModel> cm)
}
-/** Add a subpatch to this patch.
- */
-void
-PatchController::add_subpatch(PatchController* patch)
-{
- assert(patch != NULL);
- assert(patch->patch_model());
- assert(patch->patch_model()->parent());
-
- /*if (pm->x() == 0 && pm->y() == 0) {
- int x, y;
- parent_pc->get_new_module_location(x, y);
- pm->x(x);
- pm->y(y);
- }*/
-
- //patch_model()->add_node(patch->patch_model());
-
- if (m_patch_view != NULL) {
- patch->create_module(m_patch_view->canvas());
- m_patch_view->canvas()->add_module(patch->module());
- patch->module()->resize();
- }
-}
-
-
void
-PatchController::add_node(CountedPtr<NodeModel> nm)
+PatchController::add_node(CountedPtr<NodeModel> object)
{
cerr << "ADD NODE\n";
- assert(nm);
- assert(nm->parent() == m_patch_model);
- assert(nm->path().parent() == m_patch_model->path());
+ assert(object);
+ assert(object->parent() == m_patch_model);
+ assert(object->path().parent() == m_patch_model->path());
/*if (patch_model()->get_node(nm->name()) != NULL) {
cerr << "Ignoring existing\n";
// Node already exists, ignore
//delete nm;
- } else {*/
- // FIXME: Should PatchController really be responsible for creating these?
+ } else {*/
+
+
+ CountedPtr<NodeModel> node(object);
+ if (node) {
+ cerr << "\tNode Child\n";
+ assert(node->parent() == m_patch_model);
+
NodeController* nc = NULL;
-
- if (nm->plugin() && nm->plugin()->type() == PluginModel::DSSI)
- nc = new DSSIController(nm);
- else
- nc = new NodeController(nm);
+
+ CountedPtr<PatchModel> patch(node);
+ if (patch) {
+ cerr << "\t.. is a Patch Child\n";
+ assert(patch->parent() == m_patch_model);
+
+ nc = new PatchController(patch);
+ } else {
+ cerr << "\t... is a Plugin Node Child\n";
+ assert(node->plugin());
+ if (node->plugin()->type() == PluginModel::DSSI)
+ nc = new DSSIController(node);
+ else
+ nc = new NodeController(node);
+ }
assert(nc != NULL);
- assert(nm->controller() == nc);
-
+ assert(node->controller() == nc);
+
// Check if this is a bridge node - FIXME: remove this
- CountedPtr<PortModel> pm = patch_model()->get_port(nm->path().name());
+ CountedPtr<PortModel> pm = patch_model()->get_port(node->path().name());
if (pm) {
cerr << "Bridge node." << endl;
PortController* pc = ((PortController*)pm->controller());
assert(pc != NULL);
nc->bridge_port(pc);
}
-
+
//nc->add_to_store();
- //patch_model()->add_node(nm);
-
+ //patch_model()->add_node(node);
+
if (m_patch_view != NULL) {
int x, y;
get_new_module_location(x, y);
- nm->x(x);
- nm->y(y);
+ node->x(x);
+ node->y(y);
// Set zoom to 1.0 so module isn't messed up (Death to GnomeCanvas)
float old_zoom = m_patch_view->canvas()->zoom();
if (old_zoom != 1.0)
m_patch_view->canvas()->zoom(1.0);
-
+
if (nc->module() == NULL)
nc->create_module(m_patch_view->canvas());
assert(nc->module() != NULL);
m_patch_view->canvas()->add_module(nc->module());
nc->module()->resize();
-
+
// Reset zoom
if (old_zoom != 1.0) {
m_patch_view->canvas()->zoom(old_zoom);
nc->module()->zoom(old_zoom);
}
- // }
+ }
+
}
+
+
+ /*CountedPtr<PortModel> port(object);
+ if (port) {
+ cerr << "\tPort Child??\n";
+ //assert(port->parent() == m_patch_model);
+ }*/
}
diff --git a/src/progs/gtk/PatchController.h b/src/progs/gtk/PatchController.h
index 840d5fe3..236fd0b6 100644
--- a/src/progs/gtk/PatchController.h
+++ b/src/progs/gtk/PatchController.h
@@ -78,8 +78,6 @@ public:
void disconnection(const Path& src_port_path, const Path& dst_port_path);
void clear();
- void add_subpatch(PatchController* patch);
-
void get_new_module_location(int& x, int& y);
void show_control_window();
@@ -108,7 +106,7 @@ public:
void disable_controls_menuitem();
private:
- void add_node(CountedPtr<NodeModel> nm);
+ void add_node(CountedPtr<NodeModel> object);
void remove_node(const string& name);
void create_connection(CountedPtr<ConnectionModel> cm);