added a timeout for the download of icons

This commit is contained in:
Patrick von Reth 2014-01-15 11:39:59 +01:00
parent a93839fab8
commit 523c2ca18c
1 changed files with 7 additions and 3 deletions

View File

@ -110,10 +110,14 @@ void IconData::download()
request.setRawHeader("User-Agent", "SnoreNotify"); request.setRawHeader("User-Agent", "SnoreNotify");
QNetworkReply *reply = manager.get(request); QNetworkReply *reply = manager.get(request);
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
QTimer::singleShot(1000,&loop, SLOT(quit()));//timeout
loop.exec(); loop.exec();
m_data = reply->readAll(); if(reply->isFinished())
m_img = QImage::fromData(m_data, "PNG"); {
m_img.save(m_localUrl,"PNG"); m_data = reply->readAll();
m_img = QImage::fromData(m_data, "PNG");
m_img.save(m_localUrl,"PNG");
}
} }
else else
{ {