Unsolved QNetworkReply nerver finishes when connection is cut
-
Hey,
I got this code and in my main function:
QNetworkAccessManager* m = new QNetworkAccessManager(); QTimer timer; timer.setSingleShot(true); timer.connect(&timer, &QTimer::timeout, [=](){ qDebug() << "Send1"; QNetworkReply *reply = m->put(QNetworkRequest(QUrl("http://qt-project.org")), QByteArray::fromStdString("DATA")); QEventLoop loop; QObject::connect(reply,&QNetworkReply::finished,&loop,&QEventLoop::quit); if (!reply->isFinished()) { loop.exec(); } qDebug() << "Got Finished1"; reply->deleteLater(); }); QTimer timer2; timer2.setSingleShot(true); timer2.connect(&timer2, &QTimer::timeout, [=](){ qDebug() << "Send2"; QNetworkReply *reply = m->put(QNetworkRequest(QUrl("http://qt-project.org")), QByteArray::fromStdString("DATA")); QEventLoop loop; QObject::connect(reply,&QNetworkReply::finished,&loop,&QEventLoop::quit); if (!reply->isFinished()) { loop.exec(); } qDebug() << "Got Finished2"; reply->deleteLater(); }); timer.start(5000); timer2.start(10000);
Now I do the following test:
- With internet connection up -> Both requests finish!
- With internet connection down -> Both requests finish!
- Internet connection is up. I wait for the first request to finish, cut the connection. -> The second request never finishes.
What is this? A bug in qt or am I doing something wrong?
Thanks!
Nathan -
This looks like one of these bug reports:
https://bugreports.qt.io/browse/QTBUG-57390
https://bugreports.qt.io/browse/QTBUG-57799