diff options
author | David Robillard <d@drobilla.net> | 2006-06-12 04:48:20 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2006-06-12 04:48:20 +0000 |
commit | efee2b08f575e2c216cffa6f08a928223ab2cedb (patch) | |
tree | 089fdf9bc89aa04793b03cbfccb438a7a9c9f387 /src | |
parent | 5818a04533e472820f6c6748b2f07d7d1ca5789a (diff) | |
download | ingen-efee2b08f575e2c216cffa6f08a928223ab2cedb.tar.gz ingen-efee2b08f575e2c216cffa6f08a928223ab2cedb.tar.bz2 ingen-efee2b08f575e2c216cffa6f08a928223ab2cedb.zip |
Store memory bug fixes (multiple ref ptr's to the same object, bad),
control panel fixes
git-svn-id: http://svn.drobilla.net/lad/grauph@32 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/common/util/CountedPtr.h | 2 | ||||
-rw-r--r-- | src/libs/client/NodeModel.cpp | 8 | ||||
-rw-r--r-- | src/libs/client/NodeModel.h | 3 | ||||
-rw-r--r-- | src/libs/client/ObjectModel.h | 12 | ||||
-rw-r--r-- | src/libs/client/PatchLibrarian.cpp | 6 | ||||
-rw-r--r-- | src/libs/client/PatchModel.cpp | 9 | ||||
-rw-r--r-- | src/libs/client/Store.cpp | 11 | ||||
-rw-r--r-- | src/libs/client/Store.h | 3 | ||||
-rw-r--r-- | src/libs/engine/LV2Plugin.cpp | 8 | ||||
-rw-r--r-- | src/progs/gtk/ControlInterface.cpp | 2 | ||||
-rw-r--r-- | src/progs/gtk/ControlPanel.cpp | 13 | ||||
-rw-r--r-- | src/progs/gtk/Controller.cpp | 2 | ||||
-rw-r--r-- | src/progs/gtk/Makefile.am | 2 | ||||
-rw-r--r-- | src/progs/gtk/NewSubpatchWindow.cpp | 3 | ||||
-rw-r--r-- | src/progs/gtk/NodeController.cpp | 15 | ||||
-rw-r--r-- | src/progs/gtk/PatchController.cpp | 9 | ||||
-rw-r--r-- | src/progs/gtk/PatchTreeWindow.cpp | 2 | ||||
-rw-r--r-- | src/progs/gtk/PortController.cpp | 4 | ||||
-rw-r--r-- | src/progs/gtk/SubpatchModule.cpp | 2 |
19 files changed, 58 insertions, 58 deletions
diff --git a/src/common/util/CountedPtr.h b/src/common/util/CountedPtr.h index 5c2a48f0..0886bf36 100644 --- a/src/common/util/CountedPtr.h +++ b/src/common/util/CountedPtr.h @@ -101,6 +101,7 @@ public: CountedPtr& operator=(const CountedPtr& copy) { if (this != ©) { + assert(_counter != copy._counter); release(); retain(copy._counter); } @@ -112,6 +113,7 @@ public: CountedPtr& operator=(const CountedPtr<Y>& y) { if (this != (CountedPtr*)&y) { + assert(_counter != y._counter); release(); retain(y._counter); } diff --git a/src/libs/client/NodeModel.cpp b/src/libs/client/NodeModel.cpp index 3e060401..22b20858 100644 --- a/src/libs/client/NodeModel.cpp +++ b/src/libs/client/NodeModel.cpp @@ -81,22 +81,22 @@ NodeModel::set_path(const Path& p) for (PortModelList::iterator i = m_ports.begin(); i != m_ports.end(); ++i) (*i)->set_path(m_path + "/" + (*i)->name()); - if (parent_patch() != NULL && old_path.length() > 0) - parent_patch()->rename_node(old_path, p); + //if (m_parent && old_path.length() > 0) + // parent_patch()->rename_node(old_path, p); } void NodeModel::add_port(CountedPtr<PortModel> pm) { + assert(pm); assert(pm->name() != ""); assert(pm->path().length() > m_path.length()); assert(pm->path().substr(0, m_path.length()) == m_path); - assert(pm->parent() == NULL); + assert(pm->parent().get() == this); assert(!get_port(pm->name())); m_ports.push_back(pm); - pm->set_parent(this); new_port_sig.emit(pm); } diff --git a/src/libs/client/NodeModel.h b/src/libs/client/NodeModel.h index 05df5ed5..1b79905a 100644 --- a/src/libs/client/NodeModel.h +++ b/src/libs/client/NodeModel.h @@ -33,7 +33,6 @@ using std::cout; using std::cerr; using std::endl; namespace LibOmClient { -class PatchModel; class PluginModel; @@ -71,8 +70,6 @@ public: float y() const { return m_y; } void y(float a) { m_y = a; } - PatchModel* parent_patch() const { return (PatchModel*)m_parent; } - // Signals sigc::signal<void, CountedPtr<PortModel> > new_port_sig; diff --git a/src/libs/client/ObjectModel.h b/src/libs/client/ObjectModel.h index 94103c53..b9a6d75d 100644 --- a/src/libs/client/ObjectModel.h +++ b/src/libs/client/ObjectModel.h @@ -25,7 +25,7 @@ #include <cassert> #include <sigc++/sigc++.h> #include "util/Path.h" - +#include "util/CountedPtr.h" using std::string; using std::map; using std::find; using std::cout; using std::cerr; using std::endl; using Om::Path; @@ -55,8 +55,8 @@ public: inline const Path& path() const { return m_path; } virtual void set_path(const Path& p) { m_path = p; } - ObjectModel* parent() const { return m_parent; } - virtual void set_parent(ObjectModel* p) { m_parent = p; } + CountedPtr<ObjectModel> parent() const { return m_parent; } + virtual void set_parent(CountedPtr<ObjectModel> p) { m_parent = p; } ObjectController* controller() const { return m_controller; } @@ -69,9 +69,9 @@ public: // Signals sigc::signal<void, const string&, const string&> metadata_update_sig; protected: - Path m_path; - ObjectModel* m_parent; - ObjectController* m_controller; + Path m_path; + CountedPtr<ObjectModel> m_parent; + ObjectController* m_controller; // FIXME: remove map<string,string> m_metadata; diff --git a/src/libs/client/PatchLibrarian.cpp b/src/libs/client/PatchLibrarian.cpp index 532f512b..930cdccf 100644 --- a/src/libs/client/PatchLibrarian.cpp +++ b/src/libs/client/PatchLibrarian.cpp @@ -359,8 +359,8 @@ PatchLibrarian::load_patch(PatchModel* pm, bool wait, bool existing) { string filename = pm->filename(); - string additional_path = (pm->parent() == NULL) - ? "" : ((PatchModel*)pm->parent())->filename(); + string additional_path = (!pm->parent()) + ? "" : ((PatchModel*)pm->parent().get())->filename(); additional_path = additional_path.substr(0, additional_path.find_last_of("/")); filename = find_file(pm->filename(), additional_path); @@ -409,7 +409,7 @@ PatchLibrarian::load_patch(PatchModel* pm, bool wait, bool existing) if ((!xmlStrcmp(cur->name, (const xmlChar*)"name"))) { if (load_name) { assert(key != NULL); - if (pm->parent() != NULL) { + if (pm->parent()) { path = pm->parent()->base_path() + string((char*)key); } else { path = string("/") + string((char*)key); diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp index b19f7606..877f5df0 100644 --- a/src/libs/client/PatchModel.cpp +++ b/src/libs/client/PatchModel.cpp @@ -63,11 +63,10 @@ PatchModel::add_node(CountedPtr<NodeModel> nm) { assert(nm); assert(nm->name().find("/") == string::npos); - assert(nm->parent() == NULL); + assert(nm->parent().get() == this); assert(m_nodes.find(nm->name()) == m_nodes.end()); - m_nodes[nm->name()] = nm;//CountedPtr<NodeModel>(nm); - nm->set_parent(this); + m_nodes[nm->name()] = nm; new_node_sig.emit(nm); } @@ -222,9 +221,9 @@ PatchModel::remove_connection(const string& src_port_path, const string& dst_por bool PatchModel::polyphonic() const { - return (m_parent == NULL) + return (!m_parent) ? (m_poly > 1) - : (m_poly > 1) && m_poly == parent_patch()->poly() && m_poly > 1; + : (m_poly > 1) && m_poly == ((PatchModel*)m_parent.get())->poly() && m_poly > 1; } diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp index cd52af70..21470f41 100644 --- a/src/libs/client/Store.cpp +++ b/src/libs/client/Store.cpp @@ -207,11 +207,13 @@ Store::new_node_event(const string& plugin_type, const string& plugin_uri, const std::map<string, CountedPtr<ObjectModel> >::iterator pi = m_objects.find(n->path().parent()); if (pi != m_objects.end()) { - PatchModel* parent = dynamic_cast<PatchModel*>((*pi).second.get()); - if (parent) + CountedPtr<PatchModel> parent = (*pi).second; + if (parent) { + n->set_parent(parent); parent->add_node(n); - else + } else { cerr << "ERROR: new node with no parent" << endl; + } } } } @@ -251,7 +253,8 @@ Store::new_port_event(const string& path, const string& type, bool is_output) std::map<string, CountedPtr<ObjectModel> >::iterator pi = m_objects.find(p->path().parent()); if (pi != m_objects.end()) { - NodeModel* parent = dynamic_cast<NodeModel*>((*pi).second.get()); + CountedPtr<NodeModel> parent = (*pi).second; + p->set_parent(parent); if (parent) parent->add_port(p); else diff --git a/src/libs/client/Store.h b/src/libs/client/Store.h index ebcf8d8e..b17d30c2 100644 --- a/src/libs/client/Store.h +++ b/src/libs/client/Store.h @@ -17,9 +17,6 @@ #ifndef STORE_H #define STORE_H -// FIXME: for CountedPtr -#define WITH_RTTI - #include <cassert> #include <string> #include <map> diff --git a/src/libs/engine/LV2Plugin.cpp b/src/libs/engine/LV2Plugin.cpp index 1c74bca9..4cb7348d 100644 --- a/src/libs/engine/LV2Plugin.cpp +++ b/src/libs/engine/LV2Plugin.cpp @@ -82,14 +82,10 @@ LV2Plugin::instantiate() Port* port = NULL; for (size_t j=0; j < m_num_ports; ++j) { - // LV2 shortnames are guaranteed to be unique + // LV2 shortnames are guaranteed to be unique, valid C identifiers port_name = (char*)slv2_port_get_symbol(m_lv2_plugin, j); - string::size_type slash_index; - - // Replace all slashes with "-" (so they don't screw up paths) - while ((slash_index = port_name.find("/")) != string::npos) - port_name[slash_index] = '-'; + assert(port_name.find("/") == string::npos); port_path = path() + "/" + port_name; diff --git a/src/progs/gtk/ControlInterface.cpp b/src/progs/gtk/ControlInterface.cpp index eb5eee1b..2b22eee1 100644 --- a/src/progs/gtk/ControlInterface.cpp +++ b/src/progs/gtk/ControlInterface.cpp @@ -73,7 +73,7 @@ ControlInterface::new_patch_model(PatchModel* const pm) pm->plugin(plugin); }*/ - assert(pm->parent() == NULL); + assert(!pm->parent()); PatchController* patch = new PatchController(pm); //Store::instance().add_object(patch); //_app->patch_tree()->add_patch(patch); diff --git a/src/progs/gtk/ControlPanel.cpp b/src/progs/gtk/ControlPanel.cpp index 73520596..9f3279ee 100644 --- a/src/progs/gtk/ControlPanel.cpp +++ b/src/progs/gtk/ControlPanel.cpp @@ -56,7 +56,7 @@ ControlPanel::init(NodeController* node, size_t poly) assert(node != NULL); assert(poly > 0); - const CountedPtr<NodeModel> node_model = node->node_model(); + const CountedPtr<NodeModel> node_model(node->node_model()); if (poly > 1) { m_voice_spinbutton->set_range(0, poly - 1); @@ -66,9 +66,14 @@ ControlPanel::init(NodeController* node, size_t poly) for (PortModelList::const_iterator i = node_model->ports().begin(); i != node_model->ports().end(); ++i) { - PortController* pc = (PortController*)(*i)->controller(); - assert(pc != NULL); - add_port(pc); + // FIXME: + if (*i) { + PortController* pc = (PortController*)((*i)->controller()); + assert(pc != NULL); + add_port(pc); + } else { + cerr << "WTF?\n"; + } } m_callback_enabled = true; diff --git a/src/progs/gtk/Controller.cpp b/src/progs/gtk/Controller.cpp index 05ebe84a..9a85914b 100644 --- a/src/progs/gtk/Controller.cpp +++ b/src/progs/gtk/Controller.cpp @@ -91,7 +91,7 @@ Controller::create_patch_from_model(const PatchModel* pm) //int id = get_next_request_id(); //set_wait_response_id(id); create_patch_from_model(pm); - if (pm->parent() != NULL) { + if (pm->parent()) { // wait_for_response(); char temp_buf[16]; snprintf(temp_buf, 16, "%f", pm->x()); diff --git a/src/progs/gtk/Makefile.am b/src/progs/gtk/Makefile.am index 71b5c477..c9320bcc 100644 --- a/src/progs/gtk/Makefile.am +++ b/src/progs/gtk/Makefile.am @@ -6,7 +6,7 @@ MAINTAINERCLEANFILES = Makefile.in sharefilesdir = $(pkgdatadir) dist_sharefiles_DATA = om_gtk.glade om-icon.png -AM_CXXFLAGS = -DGTK_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -I$(top_srcdir)/src/common -I$(top_srcdir)/src/libs/client -DPKGDATADIR=\"$(pkgdatadir)\" @GTKMM_CFLAGS@ @LIBGLADEMM_CFLAGS@ @GNOMECANVASMM_CFLAGS@ @LOSC_CFLAGS@ @LASH_CFLAGS@ @FLOWCANVAS_CFLAGS@ +AM_CXXFLAGS = -DGTK_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -I$(top_srcdir)/src/common -I$(top_srcdir)/src/libs/client -DPKGDATADIR=\"$(pkgdatadir)\" @GTKMM_CFLAGS@ @LIBGLADEMM_CFLAGS@ @GNOMECANVASMM_CFLAGS@ @LOSC_CFLAGS@ @LASH_CFLAGS@ @FLOWCANVAS_CFLAGS@ -DWITH_RTTI om_gtk_LDADD = @GTKMM_LIBS@ @LIBGLADEMM_LIBS@ @GNOMECANVASMM_LIBS@ @LOSC_LIBS@ @LASH_LIBS@ @FLOWCANVAS_LIBS@ ../../libs/client/libomclient.la om_gtk_DEPENDENCIES = ../../libs/client/libomclient.la diff --git a/src/progs/gtk/NewSubpatchWindow.cpp b/src/progs/gtk/NewSubpatchWindow.cpp index 742f6d63..dc4e47b4 100644 --- a/src/progs/gtk/NewSubpatchWindow.cpp +++ b/src/progs/gtk/NewSubpatchWindow.cpp @@ -79,8 +79,6 @@ NewSubpatchWindow::name_changed() void NewSubpatchWindow::ok_clicked() { - cerr << "FIXME new subpatch\n"; - /* PatchModel* pm = new PatchModel( m_patch_controller->model()->base_path() + m_name_entry->get_text(), m_poly_spinbutton->get_value_as_int()); @@ -100,7 +98,6 @@ NewSubpatchWindow::ok_clicked() pm->set_metadata("module-y", temp_buf); Controller::instance().create_patch_from_model(pm); hide(); - */ } diff --git a/src/progs/gtk/NodeController.cpp b/src/progs/gtk/NodeController.cpp index cc43015d..6cc0b94e 100644 --- a/src/progs/gtk/NodeController.cpp +++ b/src/progs/gtk/NodeController.cpp @@ -53,7 +53,8 @@ NodeController::NodeController(CountedPtr<NodeModel> model) for (PortModelList::const_iterator i = node_model()->ports().begin(); i != node_model()->ports().end(); ++i) { assert(!(*i)->controller()); - assert((*i)->parent() == model.get()); + assert((*i)->parent()); + assert((*i)->parent().get() == node_model().get()); // FIXME: leak PortController* const pc = new PortController(*i); assert((*i)->controller() == pc); // PortController() does this @@ -193,7 +194,8 @@ NodeController::metadata_update(const string& key, const string& value) void NodeController::add_port(CountedPtr<PortModel> pm) { - assert(pm->parent() == node_model().get()); + assert(pm->parent().get() == node_model().get()); + assert(pm->parent() == node_model()); assert(node_model()->get_port(pm->name()) == pm); cout << "[NodeController] Adding port " << pm->path() << endl; @@ -225,9 +227,9 @@ NodeController::show_control_window() { size_t poly = 1; if (node_model()->polyphonic()) - poly = node_model()->parent_patch()->poly(); + poly = ((PatchModel*)node_model()->parent().get())->poly(); - if (m_control_window == NULL) + if (!m_control_window) m_control_window = new NodeControlWindow(this, poly); if (m_control_window->control_panel()->num_controls() > 0) @@ -245,7 +247,7 @@ NodeController::on_menu_destroy() void NodeController::show_rename_window() { - assert(node_model()->parent() != NULL); + assert(node_model()->parent()); // FIXME: will this be magically cleaned up? RenameWindow* win = NULL; @@ -265,6 +267,8 @@ NodeController::show_rename_window() void NodeController::on_menu_clone() { + cerr << "FIXME: clone broken\n"; + /* assert(node_model()); //assert(m_parent != NULL); //assert(m_parent->model() != NULL); @@ -295,6 +299,7 @@ NodeController::on_menu_clone() nm->x(node_model()->x() + 20); nm->y(node_model()->y() + 20); Controller::instance().create_node_from_model(nm); + */ } diff --git a/src/progs/gtk/PatchController.cpp b/src/progs/gtk/PatchController.cpp index ada6b003..4f639340 100644 --- a/src/progs/gtk/PatchController.cpp +++ b/src/progs/gtk/PatchController.cpp @@ -60,7 +60,6 @@ PatchController::PatchController(CountedPtr<PatchModel> model) m_module_y(0) { assert(model->path().length() > 0); - assert(model->parent() == NULL); assert(model->controller() == this); // NodeController() does this /* FIXME if (model->path() != "/") { @@ -168,13 +167,13 @@ PatchController::destroy() //Store::instance().remove_object(this); // Delete self from parent (this will delete model) - if (patch_model()->parent() != NULL) { + /*if (patch_model()->parent() != NULL) { PatchController* const parent = (PatchController*)patch_model()->parent()->controller(); assert(parent != NULL); parent->remove_node(name()); } else { //delete m_model; - } + }*/ } @@ -419,7 +418,7 @@ PatchController::add_node(CountedPtr<NodeModel> nm) cerr << "ADD NODE\n"; assert(nm); - assert(nm->parent() == m_patch_model.get()); + assert(nm->parent() == m_patch_model); assert(nm->path().parent() == m_patch_model->path()); /*if (patch_model()->get_node(nm->name()) != NULL) { @@ -506,7 +505,7 @@ void PatchController::add_port(CountedPtr<PortModel> pm) { assert(pm); - assert(pm->parent() == NULL); + assert(!pm->parent()); //cerr << "[PatchController] Adding port " << pm->path() << endl; diff --git a/src/progs/gtk/PatchTreeWindow.cpp b/src/progs/gtk/PatchTreeWindow.cpp index 78ee9428..390187b8 100644 --- a/src/progs/gtk/PatchTreeWindow.cpp +++ b/src/progs/gtk/PatchTreeWindow.cpp @@ -68,7 +68,7 @@ PatchTreeWindow::add_patch(PatchController* pc) { const CountedPtr<PatchModel> pm = pc->patch_model(); - if (pm->parent() == NULL) { + if (!pm->parent()) { Gtk::TreeModel::iterator iter = m_patch_treestore->append(); Gtk::TreeModel::Row row = *iter; if (pm->path() == "/") { diff --git a/src/progs/gtk/PortController.cpp b/src/progs/gtk/PortController.cpp index eaad6efe..fcb93b30 100644 --- a/src/progs/gtk/PortController.cpp +++ b/src/progs/gtk/PortController.cpp @@ -30,7 +30,7 @@ PortController::PortController(CountedPtr<PortModel> model) m_control_panel(NULL) { assert(model); - assert(model->parent() != NULL); + assert(model->parent()); assert(model->controller() == NULL); model->set_controller(this); @@ -54,7 +54,7 @@ PortController::remove_from_store() void PortController::destroy() { - assert(m_model->parent() != NULL); + assert(m_model->parent()); NodeController* parent = (NodeController*)m_model->parent()->controller(); assert(parent != NULL); diff --git a/src/progs/gtk/SubpatchModule.cpp b/src/progs/gtk/SubpatchModule.cpp index 9c0e78e4..8c79aed5 100644 --- a/src/progs/gtk/SubpatchModule.cpp +++ b/src/progs/gtk/SubpatchModule.cpp @@ -75,7 +75,7 @@ SubpatchModule::on_double_click(GdkEventButton* event) void SubpatchModule::browse_to_patch() { - assert(m_patch->model()->parent() != NULL); + assert(m_patch->model()->parent()); PatchController* pc = (PatchController*)m_patch->model()->parent()->controller(); assert(pc != NULL); assert(pc->window() != NULL); |