forked from qt-creator/qt-creator
PluginManager: Code clean up
Mostly refactor some explicit loops, and nicer reverse looping. Change-Id: I102b86da597b37cd496762bd776af73ec407d838 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -30,6 +30,8 @@
|
||||
#include "iplugin_p.h"
|
||||
#include "pluginmanager.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
@@ -464,6 +466,14 @@ QHash<PluginDependency, PluginSpec *> PluginSpec::dependencySpecs() const
|
||||
return d->dependencySpecs;
|
||||
}
|
||||
|
||||
bool PluginSpec::requiresAny(const QSet<PluginSpec *> &plugins) const
|
||||
{
|
||||
return Utils::anyOf(d->dependencySpecs.keys(), [this, &plugins](const PluginDependency &dep) {
|
||||
return dep.type == PluginDependency::Required
|
||||
&& plugins.contains(d->dependencySpecs.value(dep));
|
||||
});
|
||||
}
|
||||
|
||||
//==========PluginSpecPrivate==================
|
||||
|
||||
namespace {
|
||||
@@ -895,14 +905,9 @@ bool PluginSpecPrivate::resolveDependencies(const QList<PluginSpec *> &specs)
|
||||
}
|
||||
QHash<PluginDependency, PluginSpec *> resolvedDependencies;
|
||||
foreach (const PluginDependency &dependency, dependencies) {
|
||||
PluginSpec *found = 0;
|
||||
|
||||
foreach (PluginSpec *spec, specs) {
|
||||
if (spec->provides(dependency.name, dependency.version)) {
|
||||
found = spec;
|
||||
break;
|
||||
}
|
||||
}
|
||||
PluginSpec * const found = Utils::findOrDefault(specs, [&dependency](PluginSpec *spec) {
|
||||
return spec->provides(dependency.name, dependency.version);
|
||||
});
|
||||
if (!found) {
|
||||
if (dependency.type == PluginDependency::Required) {
|
||||
hasError = true;
|
||||
|
||||
Reference in New Issue
Block a user