Don't call QElapsedTimer::restart on uninitialized timer
authorOlivier Goffart <ogoffart@woboq.com>
Mon, 29 May 2017 08:48:21 +0000 (10:48 +0200)
committerOlivier Goffart <ogoffart@woboq.com>
Mon, 29 May 2017 08:51:05 +0000 (10:51 +0200)
That's an undefined behavior.
Since we don't use the return value anyway, we should just use start()

src/gui/accountstate.cpp
src/gui/activitywidget.cpp
src/gui/folder.cpp
src/libsync/discoveryphase.cpp

index e5c871f84534c95d3aea39196bad4a762ee63efd..e7ed89bc29ca9d7f9af0eac41b8947116342af50 100644 (file)
@@ -160,7 +160,7 @@ bool AccountState::isConnected() const
 
 void AccountState::tagLastSuccessfullETagRequest()
 {
-    _timeSinceLastETagCheck.restart();
+    _timeSinceLastETagCheck.start();
 }
 
 void AccountState::checkConnectivity()
index 6a55001c00a9b122960e4490424514601387a176..2d40ce8ee497c75676f0227a8b313964e4f43077 100644 (file)
@@ -348,7 +348,7 @@ void ActivityWidget::slotBuildNotificationDisplay(const ActivityList &list)
 
     if (newGuiLogCount > 0) {
         // restart the gui log timer now that we show a notification
-        _guiLogTimer.restart();
+        _guiLogTimer.start();
 
         // Assemble a tray notification
         QString msg = tr("You received %n new notification(s) from %2.", "", accNotified[accNotified.keys().at(0)]).arg(accNotified.keys().at(0));
index b17a87d0de630c47264efe5ae14b5a0140eed0ab..7c009495274e7a40b36e1f8650e9496403745708 100644 (file)
@@ -629,7 +629,7 @@ void Folder::startSync(const QStringList &pathList)
     }
     _csyncUnavail = false;
 
-    _timeSinceLastSyncStart.restart();
+    _timeSinceLastSyncStart.start();
     _syncResult.setStatus(SyncResult::SyncPrepare);
     emit syncStateChange();
 
@@ -798,7 +798,7 @@ void Folder::slotSyncFinished(bool success)
     QTimer::singleShot(200, this, SLOT(slotEmitFinishedDelayed()));
 
     _lastSyncDuration = _timeSinceLastSyncStart.elapsed();
-    _timeSinceLastSyncDone.restart();
+    _timeSinceLastSyncDone.start();
 
     // Increment the follow-up sync counter if necessary.
     if (anotherSyncNeeded == ImmediateFollowUp) {
index c4c3c874365dfc0d742f83e19d774c2cbb7ba3d2..c8f13784be060cb11489d25a0b66838fa3253b45 100644 (file)
@@ -159,11 +159,11 @@ void DiscoveryJob::update_job_update_callback(bool local,
     if (updateJob) {
         // Don't wanna overload the UI
         if (!updateJob->_lastUpdateProgressCallbackCall.isValid()) {
-            updateJob->_lastUpdateProgressCallbackCall.restart(); // first call
+            updateJob->_lastUpdateProgressCallbackCall.start(); // first call
         } else if (updateJob->_lastUpdateProgressCallbackCall.elapsed() < 200) {
             return;
         } else {
-            updateJob->_lastUpdateProgressCallbackCall.restart();
+            updateJob->_lastUpdateProgressCallbackCall.start();
         }
 
         QByteArray pPath(dirUrl);