我有以下代码用于使用线程池访问网络(也就是说,以下代码可能会被多个不同的线程同时调用。)
...
QEventLoop q;
QNetworkReply *reply;
QNetworkRequest qheader;
QNetworkAccessManager network;
QTimer tT;
tT.setSingleShot(true);
connect(&network, SIGNAL(finished(QNetworkReply*)),
&q, SLOT(quit()));
connect(&tT, SIGNAL(timeout()), &q, SLOT(quit()));
network.setProxy(Proxy);
QString url=MakeImageUrl(type,pos,zoom,LanguageStr);
qheader.setUrl(QUrl(url));
qheader.setRawHeader("User-Agent",UserAgent);
qheader.setRawHeader("Accept","*/*");
reply=network.get(qheader);
ret=reply->readAll();
reply->deleteLater();
...
然后程序有时会在reply = network.get(qheader)
崩溃,我在这里做错了吗?我试过qt5.4.1和qt4.8.6,虽然崩溃的callstack不完全相同,我只是想知道上面的代码有多正确?