summaryrefslogtreecommitdiff
path: root/src/plugincontainer.cpp
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2020-11-06 09:05:45 -0500
committerisanae <14251494+isanae@users.noreply.github.com>2020-11-06 09:05:45 -0500
commitbe9c39a3b47a8f93388eaf624b6d007eac22b68e (patch)
tree8158e26f72027388b69210fd9b1cb5b922ac9e49 /src/plugincontainer.cpp
parentdc9de3696519fab6403c386a48c84cd6781ab99c (diff)
pass null IOrganizer to proxy plugins instead of one with a null OrganizerCore
removed now useless null checks in OrganizerProxy call setPluginDataPath() early so plugins can have it, since it's now a static function in IOrganizer
Diffstat (limited to 'src/plugincontainer.cpp')
-rw-r--r--src/plugincontainer.cpp24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/plugincontainer.cpp b/src/plugincontainer.cpp
index 3ad3da21..a571a0aa 100644
--- a/src/plugincontainer.cpp
+++ b/src/plugincontainer.cpp
@@ -171,20 +171,11 @@ 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
+ // when MO has no instance loaded, init() is not called on plugins, except
+ // for proxy plugins, where init() is called with a null IOrganizer
//
- // 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
+ // 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) {
@@ -211,7 +202,12 @@ bool PluginContainer::initProxyPlugin(IPlugin *plugin)
return false;
}
- if (!plugin->init(new OrganizerProxy(m_Organizer, this, plugin))) {
+ IOrganizer* proxy = nullptr;
+ if (m_Organizer) {
+ proxy = new OrganizerProxy(m_Organizer, this, plugin);
+ }
+
+ if (!plugin->init(proxy)) {
log::warn("proxy plugin failed to initialize");
return false;
}