From 15059907c9bd0061f502c64457fce20c7e60a07f Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Thu, 12 Nov 2020 20:47:12 +0100 Subject: Proper handling of proxied plugins that implement multiple interfaces. --- src/plugincontainer.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/plugincontainer.h') diff --git a/src/plugincontainer.h b/src/plugincontainer.h index b37b48cd..89ab5528 100644 --- a/src/plugincontainer.h +++ b/src/plugincontainer.h @@ -91,11 +91,15 @@ private: // constructed object before calling init(). void fetchRequirements(); + // Set the master for this plugin. This is required to "fake" masters for proxied plugins. + void setMaster(MOBase::IPlugin* master); + friend class PluginContainer; PluginContainer* m_PluginContainer; MOBase::IPlugin* m_Plugin; MOBase::IPluginProxy* m_PluginProxy; + MOBase::IPlugin* m_Master; std::vector> m_Requirements; MOBase::IOrganizer* m_Organizer; std::vector m_RequiredFor; @@ -107,6 +111,9 @@ private: }; +/** + * + */ class PluginContainer : public QObject, public MOBase::IPluginDiagnose { @@ -229,6 +236,10 @@ public: * @param t Name of the plugin to retrieve, or non-IPlugin interface. * * @return the corresponding plugin, or a null pointer. + * + * @note It is possible to have multiple plugins for the same name when + * dealing with proxied plugins (e.g. Python), in which case the + * most important one will be returned, as specified in PluginTypeOrder. */ MOBase::IPlugin* plugin(QString const& pluginName) const; MOBase::IPlugin* plugin(MOBase::IPluginDiagnose* diagnose) const; @@ -320,6 +331,17 @@ private: friend class PluginRequirements; + /** + * @brief Check if a plugin implements a "better" interface than another + * one, as specified by PluginTypeOrder. + * + * @param lhs, rhs The plugin to compare. + * + * @return true if the left plugin implements a better interface than the right + * one, false otherwise (or if both implements the same interface). + */ + bool isBetterInterface(QObject* lhs, QObject* rhs) const; + /** * @brief Find the QObject* corresponding to the given plugin. * @@ -341,7 +363,7 @@ private: void registerGame(MOBase::IPluginGame *game); - bool registerPlugin(QObject *pluginObj, const QString &fileName, MOBase::IPluginProxy *proxy); + MOBase::IPlugin* registerPlugin(QObject *pluginObj, const QString &fileName, MOBase::IPluginProxy *proxy); OrganizerCore *m_Organizer; -- cgit v1.3.1