@@ -248,6 +248,12 @@ bool PluginManager::isEnabled(MOBase::IPlugin* plugin) const
248
248
return plugin == m_core->managedGame ();
249
249
}
250
250
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
+
251
257
return m_extensions.isEnabled (details (plugin).extension ());
252
258
}
253
259
@@ -485,8 +491,26 @@ bool PluginManager::loadPlugins(const MOBase::PluginExtension& extension)
485
491
}
486
492
487
493
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
488
508
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
+ }
490
514
}
491
515
}
492
516
@@ -693,14 +717,21 @@ std::vector<PluginManager::PluginLoaderPtr> PluginManager::makeLoaders()
693
717
694
718
// load the python proxy
695
719
{
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 );
699
724
700
725
if (auto * object = pluginLoader->instance (); object) {
701
726
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
+ }
704
735
}
705
736
}
706
737
0 commit comments