mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
Fixes multiple KVersionControlPlugin::fileName() calls on entering or updating directory.
Summary: BUG: 415698 FIXED-IN: 20.04 On each VCS plugin creation corresponding file name is saved (cached) so when we search which VCS plugin is appropriate for current directory we don't need to call KVersionControlPlugin::fileName() again. Reviewers: #dolphin, meven, elvisangelaccio, ngraham Reviewed By: #dolphin, meven, ngraham Subscribers: kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D26962
This commit is contained in:
parent
e545efee73
commit
d0cbcf9718
|
@ -303,7 +303,7 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const QUrl& director
|
||||||
if (enabledPlugins.contains((*it)->name())) {
|
if (enabledPlugins.contains((*it)->name())) {
|
||||||
KVersionControlPlugin* plugin = (*it)->createInstance<KVersionControlPlugin>(this);
|
KVersionControlPlugin* plugin = (*it)->createInstance<KVersionControlPlugin>(this);
|
||||||
if (plugin) {
|
if (plugin) {
|
||||||
m_plugins.append(plugin);
|
m_plugins.append( qMakePair(plugin, plugin->fileName()) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -323,12 +323,12 @@ 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, m_plugins) {
|
for (const auto &it : qAsConst(m_plugins)) {
|
||||||
const QString fileName = directory.path() + '/' + plugin->fileName();
|
const QString fileName = directory.path() + '/' + it.second;
|
||||||
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,
|
||||||
// instead of going through the plugin scoring procedure, we can't find a better one ;)
|
// instead of going through the plugin scoring procedure, we can't find a better one ;)
|
||||||
return plugin;
|
return it.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Version control systems like Git provide the version information
|
// Version control systems like Git provide the version information
|
||||||
|
@ -342,10 +342,10 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const QUrl& director
|
||||||
QUrl upUrl = KIO::upUrl(dirUrl);
|
QUrl upUrl = KIO::upUrl(dirUrl);
|
||||||
int upUrlCounter = 1;
|
int upUrlCounter = 1;
|
||||||
while ((upUrlCounter < bestScore) && (upUrl != dirUrl)) {
|
while ((upUrlCounter < bestScore) && (upUrl != dirUrl)) {
|
||||||
const QString fileName = dirUrl.path() + '/' + plugin->fileName();
|
const QString fileName = dirUrl.path() + '/' + it.second;
|
||||||
if (QFile::exists(fileName)) {
|
if (QFile::exists(fileName)) {
|
||||||
if (upUrlCounter < bestScore) {
|
if (upUrlCounter < bestScore) {
|
||||||
bestPlugin = plugin;
|
bestPlugin = it.first;
|
||||||
bestScore = upUrlCounter;
|
bestScore = upUrlCounter;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -114,6 +114,7 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef QPair<KFileItem, KVersionControlPlugin::ItemVersion> ItemState;
|
typedef QPair<KFileItem, KVersionControlPlugin::ItemVersion> ItemState;
|
||||||
|
typedef QPair<KVersionControlPlugin*, QString> VCSPlugin;
|
||||||
|
|
||||||
void updateItemStates();
|
void updateItemStates();
|
||||||
|
|
||||||
|
@ -157,7 +158,7 @@ private:
|
||||||
|
|
||||||
bool m_pluginsInitialized;
|
bool m_pluginsInitialized;
|
||||||
KVersionControlPlugin* m_plugin;
|
KVersionControlPlugin* m_plugin;
|
||||||
QList<KVersionControlPlugin*> m_plugins;
|
QList<VCSPlugin> m_plugins;
|
||||||
UpdateItemStatesThread* m_updateItemStatesThread;
|
UpdateItemStatesThread* m_updateItemStatesThread;
|
||||||
|
|
||||||
friend class UpdateItemStatesThread;
|
friend class UpdateItemStatesThread;
|
||||||
|
|
Loading…
Reference in a new issue