Commit 7239d03e authored by con's avatar con

Fixes: - Make plugin load order a bit more deterministic

Details:  - It will still change if the dependencies change, there's no
way to avoid that though.
parent f1e67fa3
......@@ -69,7 +69,7 @@ static const char *HELP_OPTION4 = "--help";
static const char *VERSION_OPTION = "-version";
static const char *CLIENT_OPTION = "-client";
typedef QSet<ExtensionSystem::PluginSpec *> PluginSpecSet;
typedef QList<ExtensionSystem::PluginSpec *> PluginSpecSet;
// Helpers for displaying messages. Note that there is no console on Windows.
#ifdef Q_WS_WIN
......
......@@ -129,7 +129,7 @@ bool OptionsParser::checkForNoLoadOption()
"The plugin '%1' does not exist.").arg(m_currentArg);
m_hasError = true;
} else {
m_pmPrivate->pluginSpecs.remove(spec);
m_pmPrivate->pluginSpecs.removeAll(spec);
delete spec;
m_isDependencyRefreshNeeded = true;
}
......
......@@ -48,7 +48,7 @@
#include <QTest>
#endif
typedef QSet<ExtensionSystem::PluginSpec *> PluginSpecSet;
typedef QList<ExtensionSystem::PluginSpec *> PluginSpecSet;
enum { debugLeaks = 0 };
......@@ -162,6 +162,11 @@ enum { debugLeaks = 0 };
using namespace ExtensionSystem;
using namespace ExtensionSystem::Internal;
static bool lessThanByPluginName(const PluginSpec *one, const PluginSpec *two)
{
return one->name() < two->name();
}
PluginManager *PluginManager::m_instance = 0;
/*!
......@@ -306,7 +311,7 @@ QStringList PluginManager::arguments() const
}
/*!
\fn QSet<PluginSpec *> PluginManager::plugins() const
\fn QList<PluginSpec *> PluginManager::plugins() const
List of all plugin specifications that have been found in the plugin search paths.
This list is valid directly after the setPluginPaths() call.
The plugin specifications contain the information from the plugins' xml description files
......@@ -315,7 +320,7 @@ QStringList PluginManager::arguments() const
\sa setPluginPaths()
*/
QSet<PluginSpec *> PluginManager::plugins() const
QList<PluginSpec *> PluginManager::plugins() const
{
return d->pluginSpecs;
}
......@@ -703,9 +708,11 @@ void PluginManagerPrivate::readPluginPaths()
foreach (const QString &specFile, specFiles) {
PluginSpec *spec = new PluginSpec;
spec->d->read(specFile);
pluginSpecs.insert(spec);
pluginSpecs.append(spec);
}
resolveDependencies();
// ensure deterministic plugin load order by sorting
qSort(pluginSpecs.begin(), pluginSpecs.end(), lessThanByPluginName);
emit q->pluginsChanged();
}
......
......@@ -101,7 +101,7 @@ public:
void loadPlugins();
QStringList pluginPaths() const;
void setPluginPaths(const QStringList &paths);
QSet<PluginSpec *> plugins() const;
QList<PluginSpec *> plugins() const;
void setFileExtension(const QString &extension);
QString fileExtension() const;
......
......@@ -66,7 +66,7 @@ public:
void loadPlugin(PluginSpec *spec, PluginSpec::State destState);
void resolveDependencies();
QSet<PluginSpec *> pluginSpecs;
QList<PluginSpec *> pluginSpecs;
QList<PluginSpec *> testSpecs;
QStringList pluginPaths;
QString extension;
......
......@@ -693,10 +693,10 @@ int PluginSpecPrivate::versionCompare(const QString &version1, const QString &ve
}
/*!
\fn bool PluginSpecPrivate::resolveDependencies(const QSet<PluginSpec *> &specs)
\fn bool PluginSpecPrivate::resolveDependencies(const QList<PluginSpec *> &specs)
\internal
*/
bool PluginSpecPrivate::resolveDependencies(const QSet<PluginSpec *> &specs)
bool PluginSpecPrivate::resolveDependencies(const QList<PluginSpec *> &specs)
{
if (hasError)
return false;
......
......@@ -56,7 +56,7 @@ public:
bool read(const QString &fileName);
bool provides(const QString &pluginName, const QString &version) const;
bool resolveDependencies(const QSet<PluginSpec *> &specs);
bool resolveDependencies(const QList<PluginSpec *> &specs);
bool loadLibrary();
bool initializePlugin();
bool initializeExtensions();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment