From 97faa683045e44563d25befe463e76f42c7d1a9b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 24 Sep 2007 04:52:21 +0000 Subject: Avoid thread creation and glade stuff on module/port creation (defer until menu requested). git-svn-id: http://svn.drobilla.net/lad/ingen@776 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/gui/App.cpp | 2 +- src/libs/gui/App.hpp | 4 ++-- src/libs/gui/ConnectWindow.cpp | 20 +++++++++----------- src/libs/gui/NodeModule.cpp | 19 ++++++++++++------- src/libs/gui/NodeModule.hpp | 2 ++ src/libs/gui/Port.cpp | 17 +++++++++++------ src/libs/gui/Port.hpp | 2 ++ src/libs/module/Module.cpp | 4 ++-- 8 files changed, 41 insertions(+), 29 deletions(-) diff --git a/src/libs/gui/App.cpp b/src/libs/gui/App.cpp index b07352d7..feeae181 100644 --- a/src/libs/gui/App.cpp +++ b/src/libs/gui/App.cpp @@ -130,7 +130,7 @@ App::run(int argc, char** argv, void -App::attach(const SharedPtr& engine, const SharedPtr& client) +App::attach(SharedPtr engine, SharedPtr client) { assert( ! _engine); assert( ! _client); diff --git a/src/libs/gui/App.hpp b/src/libs/gui/App.hpp index a300d04e..298fc44e 100644 --- a/src/libs/gui/App.hpp +++ b/src/libs/gui/App.hpp @@ -77,8 +77,8 @@ public: void error_message(const string& msg); - void attach(const SharedPtr& engine, - const SharedPtr& client); + void attach(SharedPtr engine, + SharedPtr client); void detach(); diff --git a/src/libs/gui/ConnectWindow.cpp b/src/libs/gui/ConnectWindow.cpp index e61b72d8..e8f93354 100644 --- a/src/libs/gui/ConnectWindow.cpp +++ b/src/libs/gui/ConnectWindow.cpp @@ -112,21 +112,19 @@ ConnectWindow::start(SharedPtr engine, SharedPtractivate(1); // FIXME - Glib::signal_timeout().connect( sigc::mem_fun(engine.get(), &Ingen::Engine::main_iteration), 1000); ThreadedSigClientInterface* tsci = new ThreadedSigClientInterface(Ingen::event_queue_size); SharedPtr client(tsci); + Glib::signal_timeout().connect( + sigc::mem_fun(tsci, &ThreadedSigClientInterface::emit_signals), 10, G_PRIORITY_HIGH_IDLE); + if (interface) App::instance().attach(interface, client); - + _connect_stage = 0; - - Glib::signal_timeout().connect( - sigc::mem_fun(tsci, &ThreadedSigClientInterface::emit_signals), 10, G_PRIORITY_HIGH_IDLE); } if (interface) { @@ -243,7 +241,7 @@ ConnectWindow::connect() assert(_new_engine); _engine = SharedPtr(_new_engine(App::instance().world())); - _engine->start_jack_driver(); + //_engine->start_jack_driver(); SharedPtr engine_interface = _engine->new_queued_interface(); @@ -252,16 +250,16 @@ ConnectWindow::connect() App::instance().attach(engine_interface, client); - _engine->activate(1); // FIXME + /*_engine->activate(1); // FIXME Glib::signal_timeout().connect( - sigc::mem_fun(_engine.get(), &Ingen::Engine::main_iteration), 1000); + sigc::mem_fun(_engine.get(), &Ingen::Engine::main_iteration), 1000);*/ Glib::signal_timeout().connect( sigc::mem_fun(this, &ConnectWindow::gtk_callback), 100); - Glib::signal_timeout().connect( - sigc::mem_fun(tsci, &ThreadedSigClientInterface::emit_signals), 10, G_PRIORITY_HIGH_IDLE); + /*Glib::signal_timeout().connect( + sigc::mem_fun(tsci, &ThreadedSigClientInterface::emit_signals), 10, G_PRIORITY_HIGH_IDLE);*/ } } diff --git a/src/libs/gui/NodeModule.cpp b/src/libs/gui/NodeModule.cpp index c80952b5..b59e1e23 100644 --- a/src/libs/gui/NodeModule.cpp +++ b/src/libs/gui/NodeModule.cpp @@ -42,19 +42,12 @@ NodeModule::NodeModule(boost::shared_ptr canvas, SharedPtr xml = GladeFactory::new_glade_reference(); - xml->get_widget_derived("object_menu", _menu); - _menu->init(node); - set_menu(_menu); node->signal_new_port.connect(sigc::bind(sigc::mem_fun(this, &NodeModule::add_port), true)); node->signal_removed_port.connect(sigc::mem_fun(this, &NodeModule::remove_port)); node->signal_metadata.connect(sigc::mem_fun(this, &NodeModule::set_metadata)); node->signal_polyphonic.connect(sigc::mem_fun(this, &NodeModule::set_stacked_border)); node->signal_renamed.connect(sigc::mem_fun(this, &NodeModule::rename)); - - _menu->signal_embed_gui.connect(sigc::mem_fun(this, &NodeModule::embed_gui)); set_stacked_border(node->polyphonic()); } @@ -71,6 +64,18 @@ NodeModule::~NodeModule() } +void +NodeModule::create_menu() +{ + Glib::RefPtr xml = GladeFactory::new_glade_reference(); + xml->get_widget_derived("object_menu", _menu); + _menu->init(_node); + _menu->signal_embed_gui.connect(sigc::mem_fun(this, &NodeModule::embed_gui)); + + set_menu(_menu); +} + + boost::shared_ptr NodeModule::create(boost::shared_ptr canvas, SharedPtr node) { diff --git a/src/libs/gui/NodeModule.hpp b/src/libs/gui/NodeModule.hpp index 8bc1bb52..b35822f4 100644 --- a/src/libs/gui/NodeModule.hpp +++ b/src/libs/gui/NodeModule.hpp @@ -79,6 +79,8 @@ protected: void embed_gui(bool embed); void gui_size_request(Gtk::Requisition* req); + + void create_menu(); SharedPtr _node; NodeMenu* _menu; diff --git a/src/libs/gui/Port.cpp b/src/libs/gui/Port.cpp index b6c64cf0..a75d9cee 100644 --- a/src/libs/gui/Port.cpp +++ b/src/libs/gui/Port.cpp @@ -44,12 +44,6 @@ Port::Port(boost::shared_ptr module, SharedPtr pm { assert(module); assert(_port_model); - - PortMenu* menu = NULL; - Glib::RefPtr xml = GladeFactory::new_glade_reference(); - xml->get_widget_derived("object_menu", menu); - menu->init(pm); - set_menu(menu); _port_model->signal_renamed.connect(sigc::mem_fun(this, &Port::renamed)); @@ -72,6 +66,17 @@ Port::Port(boost::shared_ptr module, SharedPtr pm } +void +Port::create_menu() +{ + PortMenu* menu = NULL; + Glib::RefPtr xml = GladeFactory::new_glade_reference(); + xml->get_widget_derived("object_menu", menu); + menu->init(_port_model); + set_menu(menu); +} + + void Port::renamed() { diff --git a/src/libs/gui/Port.hpp b/src/libs/gui/Port.hpp index 8da6ce49..5e7b6bbe 100644 --- a/src/libs/gui/Port.hpp +++ b/src/libs/gui/Port.hpp @@ -43,6 +43,8 @@ public: virtual ~Port() {} SharedPtr model() const { return _port_model; } + + void create_menu(); virtual void set_control(float value, bool signal); void control_changed(float value); diff --git a/src/libs/module/Module.cpp b/src/libs/module/Module.cpp index 1c6c7788..8f445340 100644 --- a/src/libs/module/Module.cpp +++ b/src/libs/module/Module.cpp @@ -56,7 +56,7 @@ load_module(const string& name) string filename = Glib::Module::build_path(dir, name); if (Glib::file_test(filename, Glib::FILE_TEST_EXISTS)) { - module = new Glib::Module(filename, Glib::MODULE_BIND_LAZY); + module = new Glib::Module(filename, Glib::MODULE_BIND_LAZY|Glib::MODULE_BIND_LOCAL); if (*module) { return SharedPtr(module); @@ -71,7 +71,7 @@ load_module(const string& name) // Try default directory if not found module = new Glib::Module( Glib::Module::build_path(INGEN_MODULE_DIR, name), - Glib::MODULE_BIND_LAZY); + Glib::MODULE_BIND_LAZY|Glib::MODULE_BIND_LOCAL); if (*module) { return SharedPtr(module); -- cgit v1.2.1