diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2020-11-04 22:50:51 -0500 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2020-11-04 22:50:51 -0500 |
| commit | dc9de3696519fab6403c386a48c84cd6781ab99c (patch) | |
| tree | 93edfd8b533fb266f6a5bfc5edde1ad6cc8f0f29 /src/plugincontainer.cpp | |
| parent | e6a87a17987de5d8e462634777df31e2cae5c1a6 (diff) | |
call init() on proxy plugins
OrganizerProxy now handles a null OrganizerCore, used for proxy plugins
changed appVersion() and pluginDataPath() so they don't need OrganizerCore
Diffstat (limited to 'src/plugincontainer.cpp')
| -rw-r--r-- | src/plugincontainer.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/plugincontainer.cpp b/src/plugincontainer.cpp index 0c71e491..3ad3da21 100644 --- a/src/plugincontainer.cpp +++ b/src/plugincontainer.cpp @@ -171,6 +171,22 @@ QObject* PluginContainer::as_qobject(MOBase::IPlugin* plugin) const bool PluginContainer::initPlugin(IPlugin *plugin)
{
+ // when MO has no instance loaded, `init()` is not called on plugins, except
+ // for proxy plugins
+ //
+ // proxy plugins are given an OrganizerProxy that has a null OrganizerCore,
+ // so there's not a lot it can do, but it can return some information; the
+ // majority of its functions are no-ops
+ //
+ // so initPlugin() (this function) is called for all plugins except proxies,
+ // and does not call init() if m_Organizer is null; initProxyPlugin() below
+ // is called only for proxy plugins and will call init() with the crippled
+ // OrganizerProxy
+ //
+ // note that after proxies are initialized, instantiate() is called for all
+ // the plugins they've discovered, but as for regular plugins, init() won't be
+ // called on them if m_OrganizerCore is null
+
if (plugin == nullptr) {
return false;
}
@@ -187,6 +203,22 @@ bool PluginContainer::initPlugin(IPlugin *plugin) return true;
}
+bool PluginContainer::initProxyPlugin(IPlugin *plugin)
+{
+ // see initPlugin() above for info
+
+ if (plugin == nullptr) {
+ return false;
+ }
+
+ if (!plugin->init(new OrganizerProxy(m_Organizer, this, plugin))) {
+ log::warn("proxy plugin failed to initialize");
+ return false;
+ }
+
+ return true;
+}
+
void PluginContainer::registerGame(IPluginGame *game)
{
@@ -272,7 +304,7 @@ bool PluginContainer::registerPlugin(QObject *plugin, const QString &fileName) }
{ // proxy plugins
IPluginProxy *proxy = qobject_cast<IPluginProxy*>(plugin);
- if (initPlugin(proxy)) {
+ if (initProxyPlugin(proxy)) {
bf::at_key<IPluginProxy>(m_Plugins).push_back(proxy);
QStringList pluginNames = proxy->pluginList(
QCoreApplication::applicationDirPath() + "/" + ToQString(AppConfig::pluginPath()));
|
