Details
-
Bug
-
Resolution: Incomplete
-
P1: Critical
-
None
-
5.15
-
None
-
Windows 10 professional (19042.1586) Intel(R) Core(TM) i5-10400F CPU @ 2.90GHz 16.0 GB 2.90 GHz qt5.15.2 win32
Description
std::thread([=] { QStringList keys = json.keys(); QUrlQuery urlParam; for (int i = 0; i < keys.count(); ++i) { QString key = keys.value(i); if (json.value(key).isString()) { urlParam.addQueryItem(key, json.value(key).toString()); } else { urlParam.addQueryItem(key, QString::number(json.value(key).toInt())); } } // qDebug() << __FUNCTION__ << __LINE__ << url.url() << urlParam.toString() << QDateTime::currentDateTime(); QUrl urlTemp(url); urlTemp.setQuery(urlParam); QNetworkRequest networkRequest; networkRequest.setUrl(urlTemp); networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); QEventLoop loop; QTimer timer; QNetworkAccessManager networkManager; QNetworkReply* pReply = networkManager.get(networkRequest); connect(&timer, SIGNAL(timeout()), pReply, SLOT(abort())); connect(this, SIGNAL(SignalStopRequest()), pReply, SLOT(abort())); connect(pReply, SIGNAL(finished()), &loop, SLOT(quit())); timer.setSingleShot(true); timer.start(nTimeOut); loop.exec(); do { if (!timer.isActive()) { // qDebug() << __FUNCTION__ << __LINE__ << "timeout" << url.url() << urlParam.toString() << QDateTime::currentDateTime(); emit SignalRequestTimeout(); break; } if (pReply->error() == QNetworkReply::OperationCanceledError) { emit SignalRequestCancel(); break; } log_info("async reply error:%s", pReply->errorString().toStdString().c_str()); QByteArray data = pReply->readAll(); // qDebug() << __FUNCTION__ << __LINE__ << url.url() << data << QDateTime::currentDateTime(); emit SignalRequestResult(data); } while (0); }).detach();
I use qnetworkaccessmanager like above, but on its destruction there is a stack like the following.