diff --git a/src/gsi/gsi/gsiClassBase.cc b/src/gsi/gsi/gsiClassBase.cc index e6548ef8f..491a03186 100644 --- a/src/gsi/gsi/gsiClassBase.cc +++ b/src/gsi/gsi/gsiClassBase.cc @@ -390,6 +390,30 @@ sm_assign (const char *name, const gsi::ClassBase *cls) return sm; } +static const std::set > &name_map_for_class (const gsi::ClassBase *cls, std::map > > &cache) +{ + if (! cls) { + static std::set > empty; + return empty; + } + + std::map > >::iterator cc = cache.find (cls); + if (cc != cache.end ()) { + return cc->second; + } + + cc = cache.insert (std::make_pair ((const gsi::ClassBase *) 0, std::set > ())).first; + cc->second = name_map_for_class (cls->base (), cache); + + for (gsi::ClassBase::method_iterator m = cls->begin_methods (); m != cls->end_methods (); ++m) { + for (gsi::MethodBase::synonym_iterator syn = (*m)->begin_synonyms (); syn != (*m)->end_synonyms (); ++syn) { + cc->second.insert (std::make_pair (syn->name, (*m)->is_static ())); + } + } + + return cc->second; +} + void ClassBase::merge_declarations () { @@ -433,6 +457,8 @@ ClassBase::merge_declarations () } } + std::map > > name_maps; + // Add to the classes the special methods and clean up the method table for (gsi::ClassBase::class_iterator c = gsi::ClassBase::begin_new_classes (); c != gsi::ClassBase::end_new_classes (); ++c) { @@ -441,12 +467,7 @@ ClassBase::merge_declarations () continue; } - std::set > name_map; - for (gsi::ClassBase::method_iterator m = c->begin_methods (); m != c->end_methods (); ++m) { - for (gsi::MethodBase::synonym_iterator syn = (*m)->begin_synonyms (); syn != (*m)->end_synonyms (); ++syn) { - name_map.insert (std::make_pair (syn->name, (*m)->is_static ())); - } - } + const std::set > &name_map = name_map_for_class (c.operator-> (), name_maps); // We don't want the declaration object to be non-const except for this case. So // we const_cast here. diff --git a/src/lay/lay/layMainWindow.cc b/src/lay/lay/layMainWindow.cc index 43e81307e..c308eeeb4 100644 --- a/src/lay/lay/layMainWindow.cc +++ b/src/lay/lay/layMainWindow.cc @@ -689,6 +689,14 @@ MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const cha MainWindow::~MainWindow () { + // avoid deferred execution later on where there isn't a valid main window anymore + // (problem case: showing a dialog inside main windows's destroyed signal - this will + // process events and trigger execution if not disabled) + if (! tl::DeferredMethodScheduler::instance ()->is_disabled ()) { + tl::DeferredMethodScheduler::instance ()->execute (); + } + tl::DeferredMethodScheduler::instance ()->enable (false); + lay::register_help_handler (0, 0); // since the configuration actions unregister themselves, we need to do this before the main diff --git a/src/rba/rba/rbaUtils.h b/src/rba/rba/rbaUtils.h index 81fd2bc75..7c1cfa30e 100644 --- a/src/rba/rba/rbaUtils.h +++ b/src/rba/rba/rbaUtils.h @@ -180,12 +180,12 @@ inline void rb_protect_init () #define RUBY_BEGIN_EXEC \ try { \ - rba::RubyInterpreter::instance()->begin_exec (); + if (rba::RubyInterpreter::instance ()) { rba::RubyInterpreter::instance ()->begin_exec (); } #define RUBY_END_EXEC \ - rba::RubyInterpreter::instance()->end_exec (); \ + if (rba::RubyInterpreter::instance ()) { rba::RubyInterpreter::instance()->end_exec (); } \ } catch (...) { \ - rba::RubyInterpreter::instance()->end_exec (); \ + if (rba::RubyInterpreter::instance ()) { rba::RubyInterpreter::instance()->end_exec (); } \ throw; \ }