[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498

Maximiliano Curia maxy at moszumanska.debian.org
Fri Oct 14 14:30:03 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=77ad933

The following commit has been merged in the master branch:
commit 77ad9336b685c57a334d31bf7d92cd6185b8cfb1
Author: Kai Uwe Broulik <kde at privat.broulik.de>
Date:   Sat Sep 10 22:52:03 2016 +0200

    [FileTransferJob] Fix division by null and use elapsed timer
    
    When sending multiple files from my phone to my PC, kdeconnectd usually received a SIGFPE.
    To get the transfer speed it divides the number of bytes received by the elapsed time which can be zero.
    
    Also, since we're only interested in the time that has elapsed, use QElapsedTimer,
    which is exactly for this. QTime::elapsed() also needs to take into account potentially
    ocurred timezone or DST changes.
    
    REVIEW: 128861
---
 core/filetransferjob.cpp | 8 ++++++--
 core/filetransferjob.h   | 4 ++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/core/filetransferjob.cpp b/core/filetransferjob.cpp
index 9ee8205..afc8e46 100644
--- a/core/filetransferjob.cpp
+++ b/core/filetransferjob.cpp
@@ -80,7 +80,7 @@ void FileTransferJob::doStart()
 void FileTransferJob::startTransfer()
 {
     setProcessedAmount(Bytes, 0);
-    mTime = QTime::currentTime();
+    mTimer.start();
     description(this, i18n("Receiving file over KDE Connect"),
                         { i18nc("File transfer origin", "From"), mFrom },
                         { i18nc("File transfer destination", "To"), mDestination.toLocalFile() });
@@ -91,7 +91,11 @@ void FileTransferJob::startTransfer()
 
     connect(mReply, &QNetworkReply::uploadProgress, this, [this](qint64 bytesSent, qint64 /*bytesTotal*/) {
         setProcessedAmount(Bytes, bytesSent);
-        emitSpeed(bytesSent/mTime.elapsed());
+
+        const auto elapsed = mTimer.elapsed();
+        if (elapsed > 0) {
+            emitSpeed(bytesSent / elapsed);
+        }
     });
     connect(mReply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error),
             this, &FileTransferJob::transferFailed);
diff --git a/core/filetransferjob.h b/core/filetransferjob.h
index ee434de..ab8368d 100644
--- a/core/filetransferjob.h
+++ b/core/filetransferjob.h
@@ -24,8 +24,8 @@
 
 #include <KJob>
 
+#include <QElapsedTimer>
 #include <QIODevice>
-#include <QTime>
 #include <QSharedPointer>
 #include <QUrl>
 #include <QNetworkReply>
@@ -69,7 +69,7 @@ private:
     QNetworkReply* mReply;
     QString mFrom;
     QUrl mDestination;
-    QTime mTime;
+    QElapsedTimer mTimer;
     qulonglong mSpeedBytes;
     qint64 mWritten;
 };

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list