QNetworkReply::ProtocolUnknownError
-
I have a simple program that spawns a couple of worker QThreads that make HTTP requests. Usually everything works fine, but every so often I get a QNetworkReply::ProtocolUnknownError on every single network request when I start the program.
I dug into the QNetworkReply code a little and found that the error is coming from qnetworkreplyimpl.cpp line 81 and is triggered because the QNetworkAccessBackend pointer (backend) is NULL. I'm using Qt 4.7.1.
Has anyone seen this error before or have any idea how to fix it?
-
The worker thread creates the QNetworkAccessManager. Basically it's:
@
void MyWorkerThread::run()
{
QNetworkAccessManager *nam = new QNetworkAccessManager();
m_reply = nam->get(m_request);
connect(m_reply, SIGNAL(finished()), this, SLOT(finishedRequest()), Qt::DirectConnection);
connect(m_reply, SIGNAL(readyRead()), this, SLOT(dataReceived()), Qt::DirectConnection);// message loop until quit() is called
exec();
delete nam;
}void MyWorkerThread::finishedRequest()
{
m_error = m_reply->error();
quit();
}@ -
Why are you using threads at all? Don't make me link "my article":http://developer.qt.nokia.com/wiki/ThreadsEventsQObjects again and again :-) Adding slots to a QThread is very dangerous, not to mention forcing the connection type to Direct.
Can you paste a full testcase? That is, a Short, Self Contained, Correct (Compilable), Example http://homepage1.nifty.com/algafield/sscce.html