diff --git a/articleview.cc b/articleview.cc index 2ed8da2e..3efd6457 100644 --- a/articleview.cc +++ b/articleview.cc @@ -1324,7 +1324,7 @@ vector< ResourceToSaveHandler * > ArticleView::saveResource( const QUrl & url, c vector< ResourceToSaveHandler * > handlers; sptr< Dictionary::DataRequest > req; - if( url.scheme() == "bres" || url.scheme() == "gico" || url.scheme() == "gdau") + if( url.scheme() == "bres" || url.scheme() == "gico" || url.scheme() == "gdau" ) { if ( url.host() == "search" ) { @@ -1357,8 +1357,14 @@ vector< ResourceToSaveHandler * > ArticleView::saveResource( const QUrl & url, c req = (*activeDicts)[ x ]->getResource( Qt4x5::Url::path( url ).mid( 1 ).toUtf8().data() ); - ResourceToSaveHandler * handler = new ResourceToSaveHandler( this, req, fileName ); + ResourceToSaveHandler * handler = new ResourceToSaveHandler( this, req, fileName, true ); handlers.push_back( handler ); + + if( req.get()->isFinished() && req.get()->dataSize() > 0 ) + { + // A request was instantly finished with success. Stop search. + return handlers; + } } catch( std::exception & e ) { @@ -2743,10 +2749,11 @@ QString ArticleView::wordAtPoint( int x, int y ) ResourceToSaveHandler::ResourceToSaveHandler( ArticleView * view, sptr< Dictionary::DataRequest > req, - QString const & fileName ) : + QString const & fileName, bool search ) : QObject( view ), req( req ), - fileName( fileName ) + fileName( fileName ), + search_req( search ) { connect( this, SIGNAL( statusBarMessage( QString, int, QPixmap ) ), view, SIGNAL( statusBarMessage( QString, int, QPixmap ) ) ); @@ -2797,9 +2804,12 @@ void ResourceToSaveHandler::downloadFinished() } else { - emit statusBarMessage( - tr( "ERROR: %1" ).arg( tr( "The referenced resource failed to download." ) ), - 10000, QPixmap( ":/icons/error.png" ) ); + if( !search_req ) + { + emit statusBarMessage( + tr( "ERROR: %1" ).arg( tr( "The referenced resource failed to download." ) ), + 10000, QPixmap( ":/icons/error.png" ) ); + } } emit done(); diff --git a/articleview.hh b/articleview.hh index 71d3569d..c06ddd17 100644 --- a/articleview.hh +++ b/articleview.hh @@ -366,7 +366,7 @@ class ResourceToSaveHandler: public QObject public: explicit ResourceToSaveHandler( ArticleView * view, sptr< Dictionary::DataRequest > req, - QString const & fileName ); + QString const & fileName, bool search = false ); signals: void done(); @@ -378,6 +378,7 @@ private slots: private: sptr< Dictionary::DataRequest > req; QString fileName; + bool search_req; }; #endif