summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/progs/ingenuity/App.cpp65
-rw-r--r--src/progs/ingenuity/App.h25
-rw-r--r--src/progs/ingenuity/ConnectWindow.cpp2
-rw-r--r--src/progs/ingenuity/PatchWindow.cpp4
-rw-r--r--src/progs/ingenuity/WindowFactory.cpp34
-rw-r--r--src/progs/ingenuity/WindowFactory.h6
6 files changed, 62 insertions, 74 deletions
diff --git a/src/progs/ingenuity/App.cpp b/src/progs/ingenuity/App.cpp
index 6470a807..00f4cee4 100644
--- a/src/progs/ingenuity/App.cpp
+++ b/src/progs/ingenuity/App.cpp
@@ -57,9 +57,7 @@ App* App::_instance = 0;
App::App()
-: _store(NULL),
- _loader(NULL),
- _configuration(new Configuration()),
+: _configuration(new Configuration()),
_about_dialog(NULL),
_window_factory(new WindowFactory()),
_enable_signal(true)
@@ -99,14 +97,27 @@ App::attach(const SharedPtr<ModelEngineInterface>& engine, const SharedPtr<SigCl
_engine = engine;
_client = client;
- _store = new Store(engine, client);
- _loader = new ThreadedLoader(engine);
+ _store = SharedPtr<Store>(new Store(engine, client));
+ _loader = SharedPtr<ThreadedLoader>(new ThreadedLoader(engine));
_patch_tree_window->init(*_store);
}
void
+App::detach()
+{
+ _window_factory->clear();
+ _store->clear();
+
+ _loader.reset();
+ _store.reset();
+ _client.reset();
+ _engine.reset();
+}
+
+
+void
App::error_message(const string& str)
{
_messages_window->post(str);
@@ -207,50 +218,6 @@ App::event_save_session_as()
}
#endif
-void
-App::add_patch_window(PatchWindow* pw)
-{
- _windows.push_back(pw);
-}
-
-
-void
-App::remove_patch_window(PatchWindow* pw)
-{
- _windows.erase(find(_windows.begin(), _windows.end(), pw));
-}
-
-
-/** Returns the number of Patch windows currently visible.
- */
-int
-App::num_open_patch_windows()
-{
- int ret = 0;
- for (list<PatchWindow*>::iterator i = _windows.begin(); i != _windows.end(); ++i)
- if ((*i)->is_visible())
- ++ret;
-
- return ret;
-}
-
-
-void
-App::disconnect()
-{
- // FIXME: this is pretty gross.. figure out the death situation better
-
- list<PatchWindow*> windows = _windows; // make a copy
-
- for (list<PatchWindow*>::iterator i = windows.begin(); i != windows.end(); ++i)
- delete (*i);
-
- _store->clear();
-
- // PatchWindow destructor removes them from the list
- assert(_windows.size() == 0);
-}
-
void
App::quit()
diff --git a/src/progs/ingenuity/App.h b/src/progs/ingenuity/App.h
index 213b572d..4d7e8e79 100644
--- a/src/progs/ingenuity/App.h
+++ b/src/progs/ingenuity/App.h
@@ -44,8 +44,6 @@ using namespace Ingen::Client;
/** GTK Graphical client */
namespace Ingenuity {
-class PatchWindow;
-class LoadPatchWindow;
class MessagesWindow;
class ConfigWindow;
class IngenuityObject;
@@ -72,16 +70,12 @@ public:
void error_message(const string& msg);
- void disconnect();
- void quit();
-
- void add_patch_window(PatchWindow* pw);
- void remove_patch_window(PatchWindow* pw);
-
- int num_open_patch_windows();
-
void attach(const SharedPtr<ModelEngineInterface>& engine,
const SharedPtr<SigClientInterface>& client);
+
+ void detach();
+
+ void quit();
ConnectWindow* connect_window() const { return _connect_window; }
Gtk::Dialog* about_dialog() const { return _about_dialog; }
@@ -89,12 +83,12 @@ public:
MessagesWindow* messages_dialog() const { return _messages_window; }
PatchTreeWindow* patch_tree() const { return _patch_tree_window; }
Configuration* configuration() const { return _configuration; }
- Store* store() const { return _store; }
- ThreadedLoader* loader() const { return _loader; }
WindowFactory* window_factory() const { return _window_factory; }
const SharedPtr<ModelEngineInterface>& engine() const { return _engine; }
const SharedPtr<SigClientInterface>& client() const { return _client; }
+ const SharedPtr<Store>& store() const { return _store; }
+ const SharedPtr<ThreadedLoader>& loader() const { return _loader; }
static inline App& instance() { assert(_instance); return *_instance; }
static void instantiate();
@@ -105,14 +99,11 @@ protected:
SharedPtr<ModelEngineInterface> _engine;
SharedPtr<SigClientInterface> _client;
-
- Store* _store;
- ThreadedLoader* _loader;
+ SharedPtr<Store> _store;
+ SharedPtr<ThreadedLoader> _loader;
Configuration* _configuration;
- list<PatchWindow*> _windows;
-
ConnectWindow* _connect_window;
MessagesWindow* _messages_window;
PatchTreeWindow* _patch_tree_window;
diff --git a/src/progs/ingenuity/ConnectWindow.cpp b/src/progs/ingenuity/ConnectWindow.cpp
index 302cb08a..66fc9dca 100644
--- a/src/progs/ingenuity/ConnectWindow.cpp
+++ b/src/progs/ingenuity/ConnectWindow.cpp
@@ -205,7 +205,7 @@ ConnectWindow::disconnect()
_connect_button->set_sensitive(false);
_disconnect_button->set_sensitive(false);
- App::instance().disconnect();
+ App::instance().detach();
init();
}
diff --git a/src/progs/ingenuity/PatchWindow.cpp b/src/progs/ingenuity/PatchWindow.cpp
index ccadb9ed..06693735 100644
--- a/src/progs/ingenuity/PatchWindow.cpp
+++ b/src/progs/ingenuity/PatchWindow.cpp
@@ -118,8 +118,6 @@ PatchWindow::PatchWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad
m_breadcrumb_box = new BreadCrumbBox();
m_breadcrumb_box->signal_patch_selected.connect(sigc::mem_fun(this, &PatchWindow::set_patch_from_path));
-
- App::instance().add_patch_window(this);
}
@@ -128,8 +126,6 @@ PatchWindow::~PatchWindow()
// Prevents deletion
//m_patch->claim_patch_view();
- //App::instance().remove_patch_window(this);
-
delete m_breadcrumb_box;
}
diff --git a/src/progs/ingenuity/WindowFactory.cpp b/src/progs/ingenuity/WindowFactory.cpp
index 33d545ca..c9ec9040 100644
--- a/src/progs/ingenuity/WindowFactory.cpp
+++ b/src/progs/ingenuity/WindowFactory.cpp
@@ -61,6 +61,36 @@ WindowFactory::~WindowFactory()
}
+void
+WindowFactory::clear()
+{
+ for (PatchWindowMap::iterator i = _patch_windows.begin(); i != _patch_windows.end(); ++i)
+ delete i->second;
+
+ _patch_windows.clear();
+
+ for (ControlWindowMap::iterator i = _control_windows.begin(); i != _control_windows.end(); ++i)
+ delete i->second;
+
+ _control_windows.clear();
+}
+
+
+/** Returns the number of Patch windows currently visible.
+ */
+size_t
+WindowFactory::num_open_patch_windows()
+{
+ size_t ret = 0;
+ for (PatchWindowMap::iterator i = _patch_windows.begin(); i != _patch_windows.end(); ++i)
+ if (i->second->is_visible())
+ ++ret;
+
+ return ret;
+}
+
+
+
PatchWindow*
WindowFactory::patch_window(SharedPtr<PatchModel> patch)
{
@@ -145,7 +175,7 @@ WindowFactory::remove_patch_window(PatchWindow* win, GdkEventAny* ignored)
if (ret == Gtk::RESPONSE_CLOSE)
App::instance().quit();
else
- return false;
+ return true;
}
PatchWindowMap::iterator w = _patch_windows.find(win->patch()->path());
@@ -155,7 +185,7 @@ WindowFactory::remove_patch_window(PatchWindow* win, GdkEventAny* ignored)
delete win;
- return true;
+ return false;
}
diff --git a/src/progs/ingenuity/WindowFactory.h b/src/progs/ingenuity/WindowFactory.h
index 194f7319..2f844160 100644
--- a/src/progs/ingenuity/WindowFactory.h
+++ b/src/progs/ingenuity/WindowFactory.h
@@ -45,11 +45,13 @@ public:
WindowFactory();
~WindowFactory();
+ size_t num_open_patch_windows();
+
PatchWindow* patch_window(SharedPtr<PatchModel> patch);
NodeControlWindow* control_window(SharedPtr<NodeModel> node);
void present_patch(SharedPtr<PatchModel> patch,
- PatchWindow* preferred = NULL,
+ PatchWindow* preferred = NULL,
SharedPtr<PatchView> patch = SharedPtr<PatchView>());
void present_controls(SharedPtr<NodeModel> node);
@@ -63,6 +65,8 @@ public:
bool remove_patch_window(PatchWindow* win, GdkEventAny* ignored = NULL);
+ void clear();
+
private:
typedef std::map<Path, PatchWindow*> PatchWindowMap;
typedef std::map<Path, NodeControlWindow*> ControlWindowMap;