Originally Posted by
ChrisW67
Run your program in your debugger and when it crashes inspect the stack back trace to determine where, and usually why, it has crashed.
It looks like it's crashing on
void QDownloader::onReadyRead()
{
file->write(reply->readAll());
}
void QDownloader::onReadyRead()
{
file->write(reply->readAll());
}
To copy to clipboard, switch view to plain text mode
So I added a quick check to isWritable() and it still end up crashing but file->isOpen() returns false.
Eventually I determined that the issue was that the finished() signal kept firing before the final readyRead() so the file would close.
I also ended up moving the
connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(onFinished(QNetworkReply*)));
connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(onFinished(QNetworkReply*)));
To copy to clipboard, switch view to plain text mode
statement to the constructor because it was calling the slot an extra time for each file downloaded.
Bookmarks