mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
[versioncontrolobserver] Do not use static plugin objects
Differential Revision: https://phabricator.kde.org/D17640 Signed-off-by: Anthony Fieroni <bvbfan@abv.bg>
This commit is contained in:
parent
df3c2c1391
commit
9a9fbae988
|
@ -37,6 +37,7 @@ VersionControlObserver::VersionControlObserver(QObject* parent) :
|
||||||
m_silentUpdate(false),
|
m_silentUpdate(false),
|
||||||
m_model(nullptr),
|
m_model(nullptr),
|
||||||
m_dirVerificationTimer(nullptr),
|
m_dirVerificationTimer(nullptr),
|
||||||
|
m_pluginsInitialized(false),
|
||||||
m_plugin(nullptr),
|
m_plugin(nullptr),
|
||||||
m_updateItemStatesThread(nullptr)
|
m_updateItemStatesThread(nullptr)
|
||||||
{
|
{
|
||||||
|
@ -256,18 +257,9 @@ int VersionControlObserver::createItemStatesList(QMap<QString, QVector<ItemState
|
||||||
return index - firstIndex; // number of processed items
|
return index - firstIndex; // number of processed items
|
||||||
}
|
}
|
||||||
|
|
||||||
KVersionControlPlugin* VersionControlObserver::searchPlugin(const QUrl& directory) const
|
KVersionControlPlugin* VersionControlObserver::searchPlugin(const QUrl& directory)
|
||||||
{
|
{
|
||||||
static bool pluginsAvailable = true;
|
if (!m_pluginsInitialized) {
|
||||||
static QList<KVersionControlPlugin*> plugins;
|
|
||||||
|
|
||||||
if (!pluginsAvailable) {
|
|
||||||
// A searching for plugins has already been done, but no
|
|
||||||
// plugins are installed
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plugins.isEmpty()) {
|
|
||||||
// No searching for plugins has been done yet. Query the KServiceTypeTrader for
|
// No searching for plugins has been done yet. Query the KServiceTypeTrader for
|
||||||
// all fileview version control plugins and remember them in 'plugins'.
|
// all fileview version control plugins and remember them in 'plugins'.
|
||||||
const QStringList enabledPlugins = VersionControlSettings::enabledPlugins();
|
const QStringList enabledPlugins = VersionControlSettings::enabledPlugins();
|
||||||
|
@ -275,16 +267,19 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const QUrl& director
|
||||||
const KService::List pluginServices = KServiceTypeTrader::self()->query(QStringLiteral("FileViewVersionControlPlugin"));
|
const KService::List pluginServices = KServiceTypeTrader::self()->query(QStringLiteral("FileViewVersionControlPlugin"));
|
||||||
for (KService::List::ConstIterator it = pluginServices.constBegin(); it != pluginServices.constEnd(); ++it) {
|
for (KService::List::ConstIterator it = pluginServices.constBegin(); it != pluginServices.constEnd(); ++it) {
|
||||||
if (enabledPlugins.contains((*it)->name())) {
|
if (enabledPlugins.contains((*it)->name())) {
|
||||||
KVersionControlPlugin* plugin = (*it)->createInstance<KVersionControlPlugin>();
|
KVersionControlPlugin* plugin = (*it)->createInstance<KVersionControlPlugin>(this);
|
||||||
if (plugin) {
|
if (plugin) {
|
||||||
plugins.append(plugin);
|
m_plugins.append(plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (plugins.isEmpty()) {
|
m_pluginsInitialized = true;
|
||||||
pluginsAvailable = false;
|
}
|
||||||
return nullptr;
|
|
||||||
}
|
if (m_plugins.empty()) {
|
||||||
|
// A searching for plugins has already been done, but no
|
||||||
|
// plugins are installed
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We use the number of upUrl() calls to find the best matching plugin
|
// We use the number of upUrl() calls to find the best matching plugin
|
||||||
|
@ -294,7 +289,7 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const QUrl& director
|
||||||
|
|
||||||
// Verify whether the current directory contains revision information
|
// Verify whether the current directory contains revision information
|
||||||
// like .svn, .git, ...
|
// like .svn, .git, ...
|
||||||
foreach (KVersionControlPlugin* plugin, plugins) {
|
foreach (KVersionControlPlugin* plugin, m_plugins) {
|
||||||
const QString fileName = directory.path() + '/' + plugin->fileName();
|
const QString fileName = directory.path() + '/' + plugin->fileName();
|
||||||
if (QFile::exists(fileName)) {
|
if (QFile::exists(fileName)) {
|
||||||
// The score of this plugin is 0 (best), so we can just return this plugin,
|
// The score of this plugin is 0 (best), so we can just return this plugin,
|
||||||
|
|
|
@ -126,7 +126,7 @@ private:
|
||||||
* Returns a matching plugin for the given directory.
|
* Returns a matching plugin for the given directory.
|
||||||
* 0 is returned, if no matching plugin has been found.
|
* 0 is returned, if no matching plugin has been found.
|
||||||
*/
|
*/
|
||||||
KVersionControlPlugin* searchPlugin(const QUrl& directory) const;
|
KVersionControlPlugin* searchPlugin(const QUrl& directory);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true, if the directory contains a version control information.
|
* Returns true, if the directory contains a version control information.
|
||||||
|
@ -143,7 +143,9 @@ private:
|
||||||
|
|
||||||
QTimer* m_dirVerificationTimer;
|
QTimer* m_dirVerificationTimer;
|
||||||
|
|
||||||
|
bool m_pluginsInitialized;
|
||||||
KVersionControlPlugin* m_plugin;
|
KVersionControlPlugin* m_plugin;
|
||||||
|
QList<KVersionControlPlugin*> m_plugins;
|
||||||
UpdateItemStatesThread* m_updateItemStatesThread;
|
UpdateItemStatesThread* m_updateItemStatesThread;
|
||||||
|
|
||||||
friend class UpdateItemStatesThread;
|
friend class UpdateItemStatesThread;
|
||||||
|
|
Loading…
Reference in a new issue