From b15864870d34a1188eda93ad215734275037278e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 11 Sep 2006 11:10:35 +0000 Subject: Switched homebrew CountedPtr to boost::shared_ptr. Factories for patch windows, controller. Robustness updated in many places. Tons of cleanups, rewrites, bugfixes, etc. git-svn-id: http://svn.drobilla.net/lad/ingen@128 a436a847-0d15-0410-975c-d299462d15a1 --- src/progs/ingenuity/PatchTreeWindow.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'src/progs/ingenuity/PatchTreeWindow.cpp') diff --git a/src/progs/ingenuity/PatchTreeWindow.cpp b/src/progs/ingenuity/PatchTreeWindow.cpp index 0f8c947a..090aba18 100644 --- a/src/progs/ingenuity/PatchTreeWindow.cpp +++ b/src/progs/ingenuity/PatchTreeWindow.cpp @@ -23,6 +23,7 @@ #include "Store.h" #include "SubpatchModule.h" #include "PatchModel.h" +#include "WindowFactory.h" #include "util/Path.h" namespace Ingenuity { @@ -74,14 +75,14 @@ PatchTreeWindow::init(Store& store) void PatchTreeWindow::new_object(CountedPtr object) { - CountedPtr patch = object; - if (patch && dynamic_cast(patch->controller())) - add_patch(dynamic_cast(patch->controller())); + CountedPtr patch = PtrCast(object); + if (patch) + add_patch(PtrCast(patch->controller())); } void -PatchTreeWindow::add_patch(PatchController* pc) +PatchTreeWindow::add_patch(CountedPtr pc) { const CountedPtr pm = pc->patch_model(); @@ -89,7 +90,7 @@ PatchTreeWindow::add_patch(PatchController* pc) Gtk::TreeModel::iterator iter = m_patch_treestore->append(); Gtk::TreeModel::Row row = *iter; if (pm->path() == "/") { - CountedPtr osc_sender = App::instance().engine(); + CountedPtr osc_sender = PtrCast(App::instance().engine()); string root_name = osc_sender ? osc_sender->engine_url() : "Internal"; // Hack off trailing '/' if it's there (ugly) //if (root_name.substr(root_name.length()-1,1) == "/") @@ -130,10 +131,8 @@ PatchTreeWindow::remove_patch(const Path& path) Gtk::TreeModel::iterator PatchTreeWindow::find_patch(Gtk::TreeModel::Children root, const Path& path) { - PatchController* pc = NULL; - for (Gtk::TreeModel::iterator c = root.begin(); c != root.end(); ++c) { - pc = (*c)[m_patch_tree_columns.patch_controller_col]; + CountedPtr pc = (*c)[m_patch_tree_columns.patch_controller_col]; if (pc->model()->path() == path) { return c; } else if ((*c)->children().size() > 0) { @@ -152,7 +151,7 @@ PatchTreeWindow::event_patch_selected() Gtk::TreeModel::iterator active = m_patch_tree_selection->get_selected(); if (active) { Gtk::TreeModel::Row row = *active; - PatchController* pc = row[m_patch_tree_columns.patch_controller_col]; + CountedPtr pc = row[m_patch_tree_columns.patch_controller_col]; } } */ @@ -166,8 +165,8 @@ PatchTreeWindow::show_patch_menu(GdkEventButton* ev) Gtk::TreeModel::iterator active = m_patch_tree_selection->get_selected(); if (active) { Gtk::TreeModel::Row row = *active; - PatchController* pc = row[m_patch_tree_columns.patch_controller_col]; - if (pc != NULL) + CountedPtr pc = row[m_patch_tree_columns.patch_controller_col]; + if (pc) pc->show_menu(ev); } } @@ -178,9 +177,9 @@ PatchTreeWindow::event_patch_activated(const Gtk::TreeModel::Path& path, Gtk::Tr { Gtk::TreeModel::iterator active = m_patch_treestore->get_iter(path); Gtk::TreeModel::Row row = *active; - PatchController* pc = row[m_patch_tree_columns.patch_controller_col]; + CountedPtr pc = row[m_patch_tree_columns.patch_controller_col]; - pc->show_patch_window(); + App::instance().window_factory()->present(pc); } @@ -191,10 +190,10 @@ PatchTreeWindow::event_patch_enabled_toggled(const Glib::ustring& path_str) Gtk::TreeModel::iterator active = m_patch_treestore->get_iter(path); Gtk::TreeModel::Row row = *active; - PatchController* pc = row[m_patch_tree_columns.patch_controller_col]; + CountedPtr pc = row[m_patch_tree_columns.patch_controller_col]; Glib::ustring patch_path = pc->model()->path(); - assert(pc != NULL); + assert(pc); if ( ! pc->patch_model()->enabled()) { if (m_enable_signal) -- cgit v1.2.1