QNetworkReply readAll error
(Qt 5.3 version) I have a strange situation with the code that I moved from one project to another. Used to work just fine... Here is the code:
Code:
void onResult(QNetworkReply* r)
{
QNetworkReply::NetworkError err = r->error(); // no error
bool isfin = r->isFinished(); // returns true;
qint64 bta = r->bytesAvailable(); // returns 988305 (correct size of a file I am trying to download)
r->setReadBufferSize(0); // to set read buffer to be unlimited size (per doc)
ba = r->readAll(); // UNHANDLED EXCEPTION at 0x5D8CA9E8 (msvcr120d.dll), qlist.h line 432
...
}
I am puzzled and will appreciate any advise or comment on what is going on and how to resolve it.
Details:
void onResult is a slot in a thread class:
Code:
{
Q_OBJECT
public:
void run() {
_uploadman.reset(new QNetworkAccessManager());
..
connect(_uploadman.get(), SIGNAL(finished(QNetworkReply*)), this, SLOT(onResult(QNetworkReply*)));
_uploadman->get(upload);
exec();
}
private slots:
void onResult(QNetworkReply* r);
..
}
Re: QNetworkReply readAll error
Any chance your usage of setting the read buffer to unlimited is resulting in an out of memory condition and an invalid pointer results? Have you tried removing the call to setReadBuffer or setting to a fixed value to test?
Re: QNetworkReply readAll error
Original code looked like that:
Code:
void onResult(QNetworkReply* r)
{
if (r == nullptr)
return;
...
}
I also tried to set size of "ba" to fixed value greater then # of available bytes. Looks like the corruption of QNetworkReply instance, but I can't figure out why it happens.
Added after 1 5 minutes:
The issue is closed. It was a threading issue after all.