OSDN Git Service

Fix progress bar for searching in files.
authorcon <qtc-committer@nokia.com>
Mon, 28 Mar 2011 11:35:43 +0000 (13:35 +0200)
committercon <qtc-committer@nokia.com>
Mon, 28 Mar 2011 12:53:32 +0000 (14:53 +0200)
Affects e.g. Advanced Find->All Projects. Progress bar was not updating
at all, except at the end of the search.
The fix is a workaround for regression in
QFutureInterface::isProgressUpdateNeeded that would no longer return
true the very first time in Qt 4.7. To be reverted when this is fixed
in a released Qt version.

Reviewed-by: dt
src/libs/utils/filesearch.cpp
src/plugins/locator/directoryfilter.cpp

index c576e32..c38d160 100644 (file)
@@ -178,7 +178,8 @@ void runFileSearch(QFutureInterface<FileSearchResultList> &future,
         }
 
         ++numFilesSearched;
-        if (future.isProgressUpdateNeeded()) {
+        if (future.isProgressUpdateNeeded()
+                || future.progressValue() == 0 /*workaround for regression in Qt*/) {
             if (!results.isEmpty()) {
                 future.reportResult(results);
                 results.clear();
@@ -256,7 +257,8 @@ void runFileSearchRegExp(QFutureInterface<FileSearchResultList> &future,
             ++lineNr;
         }
         ++numFilesSearched;
-        if (future.isProgressUpdateNeeded()) {
+        if (future.isProgressUpdateNeeded()
+                || future.progressValue() == 0 /*workaround for regression in Qt*/) {
             if (!results.isEmpty()) {
                 future.reportResult(results);
                 results.clear();
index 2779eba..45d1319 100644 (file)
@@ -203,7 +203,8 @@ void DirectoryFilter::refresh(QFutureInterface<void> &future)
     QStringList filesFound;
     while (!future.isCanceled() && it.hasNext()) {
         filesFound << it.next();
-        if (future.isProgressUpdateNeeded()) {
+        if (future.isProgressUpdateNeeded()
+                || future.progressValue() == 0 /*workaround for regression in Qt*/) {
             future.setProgressValueAndText(it.currentProgress(),
                                            tr("%1 filter update: %n files", 0, filesFound.size()).arg(m_name));
         }