diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp index 5a0cd052782..cf4d5f1f4ff 100644 --- a/src/network/access/qnetworkreplyhttpimpl.cpp +++ b/src/network/access/qnetworkreplyhttpimpl.cpp @@ -1168,7 +1168,8 @@ void QNetworkReplyHttpImplPrivate::replyDownloadData(QByteArray d) emit q->readyRead(); // emit readyRead before downloadProgress in case this will cause events to be // processed and we get into a recursive call (as in QProgressDialog). - if (downloadProgressSignalChoke.elapsed() >= progressSignalInterval + if (downloadProgressSignalChoke.isValid() && + downloadProgressSignalChoke.elapsed() >= progressSignalInterval && (!decompressHelper.isValid() || decompressHelper.isCountingBytes())) { downloadProgressSignalChoke.restart(); emit q->downloadProgress(bytesDownloaded, totalSizeOpt.value_or(-1)); @@ -1501,7 +1502,8 @@ void QNetworkReplyHttpImplPrivate::replyDownloadProgressSlot(qint64 bytesReceive // processed and we get into a recursive call (as in QProgressDialog). if (bytesDownloaded > 0) emit q->readyRead(); - if (downloadProgressSignalChoke.elapsed() >= progressSignalInterval) { + if (downloadProgressSignalChoke.isValid() && + downloadProgressSignalChoke.elapsed() >= progressSignalInterval) { downloadProgressSignalChoke.restart(); emit q->downloadProgress(bytesDownloaded, bytesTotal); } @@ -1938,7 +1940,8 @@ void QNetworkReplyHttpImplPrivate::_q_cacheLoadReadyRead() // This readyRead() goes to the user. The user then may or may not read() anything. emit q->readyRead(); - if (downloadProgressSignalChoke.elapsed() >= progressSignalInterval) { + if (downloadProgressSignalChoke.isValid() && + downloadProgressSignalChoke.elapsed() >= progressSignalInterval) { downloadProgressSignalChoke.restart(); emit q->downloadProgress(bytesDownloaded, totalSizeOpt.value_or(-1)); } diff --git a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp index 25183fccd76..1a3d161e788 100644 --- a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp @@ -987,7 +987,7 @@ void tst_QTextStream::performance() }; int elapsed[N] = {0, 0, 0}; - stopWatch.restart(); + stopWatch.start(); int nlines1 = 0; QFile file(m_rfc3261FilePath); QVERIFY(file.open(QFile::ReadOnly)); @@ -997,8 +997,7 @@ void tst_QTextStream::performance() file.readLine(); } - elapsed[0] = stopWatch.elapsed(); - stopWatch.restart(); + elapsed[0] = stopWatch.restart(); int nlines2 = 0; QFile file2(m_rfc3261FilePath); @@ -1010,8 +1009,7 @@ void tst_QTextStream::performance() stream.readLine(); } - elapsed[1] = stopWatch.elapsed(); - stopWatch.restart(); + elapsed[1] = stopWatch.restart(); int nlines3 = 0; QFile file3(m_rfc3261FilePath); @@ -1022,7 +1020,7 @@ void tst_QTextStream::performance() while (stream2.readLineInto(&line)) ++nlines3; - elapsed[2] = stopWatch.elapsed(); + elapsed[2] = stopWatch.restart(); QCOMPARE(nlines1, nlines2); QCOMPARE(nlines2, nlines3);