Re: Proper file downloading?
Run your program in your debugger and when it crashes inspect the stack back trace to determine where, and usually why, it has crashed.
Re: Proper file downloading?
Quote:
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
Code:
void QDownloader::onReadyRead()
{
file->write(reply->readAll());
}
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
Code:
connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(onFinished(QNetworkReply*)));
statement to the constructor because it was calling the slot an extra time for each file downloaded.
Re: Proper file downloading?
Looking at that code you should not need that connect() from the manager at all. You either connect to the QNetworkAccessManager::finished() signal or the QNetworkReply::finished() signal but not both. It's unlikely the reply's finished signal would come before the reply's last readyRead so I would use those.
Re: Proper file downloading?
Thanks a bunch, it's running flawlessly!