PDA

View Full Version : Qt 5.1 file not downloading from web on first attempt



te777
27th July 2013, 22:12
I have a problem that occurs with Qt 5.1 (Linux Mint 15 32 bit in Virtualbox) that didn't happen with Qt 5.0.2. I have 2 classes that respond to an update button each, to download an updated input file for each class from the web. The first press of either download button returns a 0 byte file, with button any subsequent button presses working fine, while the GUI app is still running. Restart the app and the problem re-occurs. Here's the download procedure I'm using in each of my classes:

void class1::downloadFile(const QString &url, const QString &aPathInClient)
{
QNetworkAccessManager m_NetworkMngr;// = new QNetworkAccessManager(this);
QNetworkReply *reply= m_NetworkMngr.get(QNetworkRequest(url));
QEventLoop loop;
QObject::connect(reply, SIGNAL(finished()),&loop, SLOT(quit()));
loop.exec();
QUrl aUrl(url);
QFileInfo fileInfo=aUrl.path();

QFile file(aPathInClient+"/"+fileInfo.fileName());
file.open(QIODevice::WriteOnly);
file.write(reply->readAll());
file.close();

delete reply;
}

Any insight into this problem would be much appreciated. I have a 64 bit Linux Mint 15 virtual machine that I haven't tried it on yet, and also I haven't tried it on my Windows 7 64 bit host, using msvc2012 32bit. Any code change suggestions are welcome. Like I said, everything worked fine with Qt 5.0.2, both Linux virtual machines, and the Windows 7 host. Thanks in advance for any replies.

Edit: I found out it also happens with Qt 5.0.2

Infinity
27th July 2013, 22:57
Use [code] tags when posting code next time.


Any code change suggestions are welcome.
Check out the HTTP Example project.