From 9a9ab6e50cbfaee56a3d3b84ed7bea2f987985df Mon Sep 17 00:00:00 2001 From: Emmanuel Pescosta Date: Tue, 25 Feb 2014 19:38:57 +0100 Subject: Fix Bug 330605 - Dropbox plugin prevents git plugin from working Use scoring to find the best matching plugin for the given directory. Thanks to Phil Schaf for testing this patch! BUG: 330605 FIXED-IN: 4.12.3 REVIEW: 116019 --- src/views/versioncontrol/versioncontrolobserver.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/views/versioncontrol') diff --git a/src/views/versioncontrol/versioncontrolobserver.cpp b/src/views/versioncontrol/versioncontrolobserver.cpp index 4d939ee0d..769c290f9 100644 --- a/src/views/versioncontrol/versioncontrolobserver.cpp +++ b/src/views/versioncontrol/versioncontrolobserver.cpp @@ -322,11 +322,18 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& director } } + // We use the number of upUrl() calls to find the best matching plugin + // for the given directory. The smaller value, the better it is (0 is best). + KVersionControlPlugin* bestPlugin = 0; + int bestScore = INT_MAX; + // Verify whether the current directory contains revision information // like .svn, .git, ... foreach (KVersionControlPlugin* plugin, plugins) { const QString fileName = directory.path(KUrl::AddTrailingSlash) + plugin->fileName(); if (QFile::exists(fileName)) { + // 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 ;) return plugin; } @@ -339,18 +346,24 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& director if (m_versionedDirectory) { KUrl dirUrl(directory); KUrl upUrl = dirUrl.upUrl(); - while (upUrl != dirUrl) { + int upUrlCounter = 1; + while ((upUrlCounter < bestScore) && (upUrl != dirUrl)) { const QString fileName = dirUrl.path(KUrl::AddTrailingSlash) + plugin->fileName(); if (QFile::exists(fileName)) { - return plugin; + if (upUrlCounter < bestScore) { + bestPlugin = plugin; + bestScore = upUrlCounter; + } + break; } dirUrl = upUrl; upUrl = dirUrl.upUrl(); + ++upUrlCounter; } } } - return 0; + return bestPlugin; } bool VersionControlObserver::isVersioned() const -- cgit v1.3 From 272cbbd16b03e51b30b6b9d472aa56054a5ea036 Mon Sep 17 00:00:00 2001 From: Emmanuel Pescosta Date: Thu, 24 Apr 2014 20:57:18 +0200 Subject: Fix memory leak with Dropbox version control plugin. In the current version we only call endRetrieval when beginRetrieval was successfully in UpdateItemStatesThread::run(). This causes some problems with version control plugins (like Dropbox plugin), which have to do cleanups in endRetrieval. Now we always call endRetrieval after beginRetrieval when updating the version states. FIXED-IN: 4.13.1 REVIEW: 117753 --- src/views/versioncontrol/updateitemstatesthread.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/views/versioncontrol') diff --git a/src/views/versioncontrol/updateitemstatesthread.cpp b/src/views/versioncontrol/updateitemstatesthread.cpp index 6457f607d..62fcd09aa 100644 --- a/src/views/versioncontrol/updateitemstatesthread.cpp +++ b/src/views/versioncontrol/updateitemstatesthread.cpp @@ -64,9 +64,9 @@ void UpdateItemStatesThread::run() items[i].version = static_cast(state); } } - - m_plugin->endRetrieval(); } + + m_plugin->endRetrieval(); } } -- cgit v1.3