[SCM] Kaboom - Debian KDE 3->4 migration tool branch, master, updated. 2cf0ec6b2fda266f2ff9b07f28a0667d8eb17efd

George Kiagiadakis gkiagia-guest at alioth.debian.org
Thu Feb 19 10:56:54 UTC 2009


The following commit has been merged in the master branch:
commit 2cf0ec6b2fda266f2ff9b07f28a0667d8eb17efd
Author: George Kiagiadakis <gkiagia at users.sourceforge.net>
Date:   Thu Feb 19 14:52:02 2009 +0200

    If no work needs to be done, set the progress bar directly to 100% in recursiveCpDir and recursiveRmDir.
    This is to avoid showing a busy indicator on the progress bar after those functions have returned.

diff --git a/diroperations/diroperations.cpp b/diroperations/diroperations.cpp
index 992f5ea..85ff74b 100644
--- a/diroperations/diroperations.cpp
+++ b/diroperations/diroperations.cpp
@@ -19,6 +19,7 @@
 #include <QDir>
 #include <QFileInfo>
 #include <QStack>
+#include <QDebug>
 #include <climits> //for PATH_MAX
 
 namespace DirOperations {
@@ -118,8 +119,15 @@ void recursiveCpDir(const QString & sourcePath, const QString & destPath, CopyOp
     qint64 bytesCopied = 0;
 
     if ( pd ) {
-        pd->setMaximum(calculateDirSize(sourcePath, pd));
         pd->setLabelText(QObject::tr("Copying files..."));
+        qint64 dirSize = calculateDirSize(sourcePath, pd);
+        if (dirSize > 0) {
+            pd->setMaximum(dirSize);
+        } else {
+            //no files to be copied, so set the progressbar to 100%
+            pd->setMaximum(1);
+            pd->setValue(1);
+        }
     }
 
     while(1)
@@ -194,9 +202,16 @@ void recursiveCpDir(const QString & sourcePath, const QString & destPath, CopyOp
 void recursiveRmDir(const QString & dir, ProgressDialogInterface *pd)
 {
     QDir currentDir(dir);
-    if ( !currentDir.exists() )
-        return; // directory gone, no need to bother about exceptions
-        
+    if ( !currentDir.exists() ) {
+        qWarning() << "recursiveRmDir: trying to remove non-existent directory" << dir;
+        if (pd) {
+            //no files to be removed, so set the progressbar to 100%
+            pd->setMaximum(1);
+            pd->setValue(1);
+        }
+        return; // directory gone, no work to do
+    }
+
     QDir::Filters filters = QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System | QDir::CaseSensitive;
     QFileInfoList currentList = currentDir.entryInfoList( filters, QDir::DirsLast );
     QFileInfo currentItem;
@@ -204,8 +219,15 @@ void recursiveRmDir(const QString & dir, ProgressDialogInterface *pd)
     qint64 bytesRemoved = 0;
 
     if ( pd ) {
-        pd->setMaximum(calculateDirSize(dir, pd));
         pd->setLabelText(QObject::tr("Removing files..."));
+        qint64 dirSize = calculateDirSize(dir, pd);
+        if (dirSize > 0) {
+            pd->setMaximum(dirSize);
+        } else {
+            //no files to be removed, so set the progressbar to 100%
+            pd->setMaximum(1);
+            pd->setValue(1);
+        }
     }
 
     while(1)

-- 
Kaboom - Debian KDE 3->4 migration tool



More information about the pkg-kde-commits mailing list