From ad79ac7e21d75a8afdfecb6057eb6867fc3fb990 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Mon, 13 Apr 2009 01:22:49 +0200 Subject: [PATCH] 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. --- src/core/web_resources_provider.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/web_resources_provider.cpp b/src/core/web_resources_provider.cpp index a585c7301..d5f8f9604 100644 --- a/src/core/web_resources_provider.cpp +++ b/src/core/web_resources_provider.cpp @@ -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 ); } }