Skip to content

Commit

Permalink
Plugins: a selectable plugin cannot be needed by another plugin (#2247).
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Dec 3, 2019
1 parent d97d363 commit 090abdc
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
4 changes: 4 additions & 0 deletions i18n/OpenCOR_fr.ts
Expand Up @@ -253,6 +253,10 @@
<source>the plugin claims to be the core plugin, but it does not support the core interface.</source>
<translation>l&apos;extension prétend être l&apos;extension de base, mais elle ne supporte pas l&apos;interface de base.</translation>
</message>
<message>
<source>the plugin claims to be selectable, but it is needed.</source>
<translation>l&apos;extension prétend être sélectionnable, mais elle est nécessaire.</translation>
</message>
<message>
<source>the plugin supports the CLI interface, but it does not claim to be CLI-capable.</source>
<translation>l&apos;extension supporte l&apos;interface CLI, mais elle ne prétend pas être capable de CLI.</translation>
Expand Down
4 changes: 4 additions & 0 deletions src/misc/cliapplication.cpp
Expand Up @@ -445,6 +445,10 @@ void CliApplication::status() const
case Plugin::Status::InvalidCorePlugin:
pluginInfo += "the plugin claims to be the core plugin, but it does not support the core interface.";

break;
case Plugin::Status::NeededSelectablePlugin:
pluginInfo += "the plugin claims to be selectable, but it is needed.";

break;
case Plugin::Status::NotCliPluginNoCliSupport:
pluginInfo += "the plugin supports the CLI interface, but it does not claim to be CLI-capable.";
Expand Down
10 changes: 6 additions & 4 deletions src/plugins/plugin.cpp
Expand Up @@ -59,17 +59,19 @@ namespace OpenCOR {
//==============================================================================

Plugin::Plugin(const QString &pFileName, PluginInfo *pInfo,
const QString &pErrorMessage, bool pLoad,
const QString &pErrorMessage, bool pLoad, bool pNeeded,
PluginManager *pPluginManager) :
mName(name(pFileName)),
mInfo(pInfo),
mErrorMessage(pErrorMessage)
{
if (pInfo != nullptr) {
// We are dealing with a plugin, so try to load it, but only if the user
// wants
// We are dealing with a plugin, so try to load it (if needed), but
// before that make sure that it is not both needed and selectable

if (pLoad) {
if (pNeeded && pInfo->isSelectable()) {
mStatus = Status::NeededSelectablePlugin;
} else if (pLoad) {
// Make sure that the plugin's dependencies, if any, are loaded
// before loading the plugin itself
// Note: normally, we would only do this on Windows systems since,
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/plugin.h
Expand Up @@ -75,13 +75,14 @@ class Plugin : public QObject
OldPlugin,
NotCorePlugin,
InvalidCorePlugin,
NeededSelectablePlugin,
NotCliPluginNoCliSupport,
NotCliPluginNoCliInterface,
MissingOrInvalidDependencies
};

explicit Plugin(const QString &pFileName, PluginInfo *pInfo,
const QString &pErrorMessage, bool pLoad,
const QString &pErrorMessage, bool pLoad, bool pNeeded,
PluginManager *pPluginManager);
~Plugin() override;

Expand Down
3 changes: 2 additions & 1 deletion src/plugins/pluginmanager.cpp
Expand Up @@ -171,7 +171,8 @@ PluginManager::PluginManager(bool pGuiMode) :
auto plugin = new Plugin(pluginFileName,
pluginsInfo.value(pluginName),
pluginsError.value(pluginName),
plugins.contains(pluginName), this);
plugins.contains(pluginName),
neededPlugins.contains(pluginName), this);

// Keep track of the plugin and of the Core plugin, in particular, if it
// is loaded
Expand Down
2 changes: 2 additions & 0 deletions src/pluginsdialog.cpp
Expand Up @@ -285,6 +285,8 @@ QString PluginsDialog::statusDescription(Plugin *pPlugin) const
return tr("the plugin claims to be the core plugin, but it is not.");
case Plugin::Status::InvalidCorePlugin:
return tr("the plugin claims to be the core plugin, but it does not support the core interface.");
case Plugin::Status::NeededSelectablePlugin:
return tr("the plugin claims to be selectable, but it is needed.");
case Plugin::Status::NotCliPluginNoCliSupport:
return tr("the plugin supports the CLI interface, but it does not claim to be CLI-capable.");
case Plugin::Status::NotCliPluginNoCliInterface:
Expand Down

0 comments on commit 090abdc

Please sign in to comment.