WebResourcesProvider: more safely manage download IDs

Do not add download ID returned by QHttp::get() to array and remove it
in the finishDownload() slot rather than adding the ID to the array as
soon as the download has finished.
This commit is contained in:
Tobias Doerffel
2009-04-13 01:22:49 +02:00
parent 69ff06e1b9
commit ad79ac7e21

View File

@@ -92,7 +92,7 @@ QByteArray WebResourcesProvider::fetchData( const ResourcesItem * _item,
void WebResourcesProvider::finishDownload( int _id, bool a )
{
m_downloadIDs.removeAll( _id );
m_downloadIDs << _id;
}
@@ -200,14 +200,14 @@ void WebResourcesProvider::download( const QString & _path,
QBuffer * _target, bool _wait ) const
{
const int id = m_http->get( _path, _target );
m_downloadIDs << id;
if( _wait )
{
while( m_downloadIDs.contains( id ) )
while( !m_downloadIDs.contains( id ) )
{
QCoreApplication::instance()->processEvents();
}
m_downloadIDs.removeAll( id );
}
}