https://bugs.kde.org/show_bug.cgi?id=383843

--- Comment #2 from Kevin Funk <kf...@kde.org> ---
Introduced by this commit:

commit dca3d5cfd19375f61dd7d8232586227af3f4b34b
Author: David Gil <davidgilol...@gmail.com>
Date:   Fri Jun 7 22:06:15 2013 +0200

    Port time_t to QDateTime in SlaveBase (KIO)


... with the following interesting hunks of the diff:

-void SlaveBase::processedSize( KIO::filesize_t _bytes )
+void SlaveBase::processedSize(KIO::filesize_t _bytes)
 {
-    bool           emitSignal=false;
-    struct timeval tv;
-    int            gettimeofday_res=gettimeofday( &tv, 0L );
+    bool emitSignal = false;
+
+    QDateTime now = QDateTime::currentDateTime();

-    if( _bytes == d->totalSize )
+    if (_bytes == d->totalSize)
         emitSignal=true;
-    else if ( gettimeofday_res == 0 ) {
-        time_t msecdiff = 2000;
-        if (d->last_tv.tv_sec) {
-            // Compute difference, in ms
-            msecdiff = 1000 * ( tv.tv_sec - d->last_tv.tv_sec );
-            time_t usecdiff = tv.tv_usec - d->last_tv.tv_usec;
-            if ( usecdiff < 0 ) {
-                msecdiff--;
-                msecdiff += 1000;
-            }
-            msecdiff += usecdiff / 1000;
-        }
-        emitSignal=msecdiff >= 100; // emit size 10 times a second
+    else {
+        if (d->lastTimeout.isValid())
+            emitSignal = d->lastTimeout.msecsTo(now); // emit size 10 times a
second
+        else
+            emitSignal = true;
     }

-    if( emitSignal ) {
+    if (emitSignal) {
         KIO_DATA << KIO_FILESIZE_T(_bytes);
-        send( INF_PROCESSED_SIZE, data );
-        if ( gettimeofday_res == 0 ) {
-            d->last_tv.tv_sec = tv.tv_sec;
-            d->last_tv.tv_usec = tv.tv_usec;
-        }
+        send(INF_PROCESSED_SIZE, data);
+        d->lastTimeout = now;
     }
-//    d->processed_size = _bytes;
+
+    //    d->processed_size = _bytes;
 }

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to