@@ -248,6 +248,12 @@ bool PluginManager::isEnabled(MOBase::IPlugin* plugin) const
248248 return plugin == m_core->managedGame ();
249249 }
250250
251+ // check the master of the group
252+ const auto & d = details (plugin);
253+ if (d.master () && d.master () != plugin) {
254+ return isEnabled (d.master ());
255+ }
256+
251257 return m_extensions.isEnabled (details (plugin).extension ());
252258}
253259
@@ -485,8 +491,26 @@ bool PluginManager::loadPlugins(const MOBase::PluginExtension& extension)
485491 }
486492
487493 for (auto & objectGroup : objects) {
494+
495+ // safety for min_element
496+ if (objectGroup.isEmpty ()) {
497+ continue ;
498+ }
499+
500+ // find the best interface
501+ auto it = std::min_element (std::begin (objectGroup), std::end (objectGroup),
502+ [&](auto const & lhs, auto const & rhs) {
503+ return isBetterInterface (lhs, rhs);
504+ });
505+ IPlugin* master = qobject_cast<IPlugin*>(*it);
506+
507+ // register plugins in the group
488508 for (auto * object : objectGroup) {
489- registerPlugin (extension, object, objectGroup);
509+ IPlugin* plugin = registerPlugin (extension, object, objectGroup);
510+
511+ if (plugin) {
512+ m_details.at (plugin).m_master = master;
513+ }
490514 }
491515 }
492516
@@ -693,14 +717,21 @@ std::vector<PluginManager::PluginLoaderPtr> PluginManager::makeLoaders()
693717
694718 // load the python proxy
695719 {
696- auto pluginLoader = std::make_unique<QPluginLoader>(
697- QCoreApplication::applicationDirPath () + " /proxies/python/python_proxy.dll" ,
698- this );
720+ const QString proxyPath =
721+ QCoreApplication::applicationDirPath () + " /proxies/python" ;
722+ auto pluginLoader =
723+ std::make_unique<QPluginLoader>(proxyPath + " /python_proxy.dll" , this );
699724
700725 if (auto * object = pluginLoader->instance (); object) {
701726 auto loader = qobject_cast<MOBase::IPluginLoader*>(object);
702- loaders.push_back (
703- PluginLoaderPtr (loader, PluginLoaderDeleter{pluginLoader.release ()}));
727+ QString errorMessage;
728+
729+ if (loader->initialize (errorMessage)) {
730+ loaders.push_back (
731+ PluginLoaderPtr (loader, PluginLoaderDeleter{pluginLoader.release ()}));
732+ } else {
733+ log::error (" failed to initialize proxy from '{}': {}" , proxyPath, errorMessage);
734+ }
704735 }
705736 }
706737
0 commit comments