mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
Add request cancellation
This commit is contained in:
parent
07a8734bca
commit
5e49c32b53
|
@ -285,7 +285,7 @@ ArticleRequest::ArticleRequest(
|
|||
sptr< Dictionary::WordSearchRequest > s = activeDicts[ x ]->findHeadwordsForSynonym( gd::toWString( word ) );
|
||||
|
||||
connect( s.get(), SIGNAL( finished() ),
|
||||
this, SLOT( altSearchFinished() ) );
|
||||
this, SLOT( altSearchFinished() ), Qt::QueuedConnection );
|
||||
|
||||
altSearches.push_back( s );
|
||||
}
|
||||
|
@ -338,7 +338,7 @@ void ArticleRequest::altSearchFinished()
|
|||
gd::toWString( contexts.value( QString::fromStdString( activeDicts[ x ]->getId() ) ) ) );
|
||||
|
||||
connect( r.get(), SIGNAL( finished() ),
|
||||
this, SLOT( bodyFinished() ) );
|
||||
this, SLOT( bodyFinished() ), Qt::QueuedConnection );
|
||||
|
||||
bodyRequests.push_back( r );
|
||||
}
|
||||
|
@ -812,3 +812,27 @@ std::string ArticleRequest::escapeSpacing( QString const & str )
|
|||
|
||||
return spacing.data();
|
||||
}
|
||||
|
||||
void ArticleRequest::cancel()
|
||||
{
|
||||
if( isFinished() )
|
||||
return;
|
||||
if( !altSearches.empty() )
|
||||
{
|
||||
for( list< sptr< Dictionary::WordSearchRequest > >::iterator i =
|
||||
altSearches.begin(); i != altSearches.end(); ++i )
|
||||
{
|
||||
(*i)->cancel();
|
||||
}
|
||||
}
|
||||
if( !bodyRequests.empty() )
|
||||
{
|
||||
for( list< sptr< Dictionary::DataRequest > >::iterator i =
|
||||
bodyRequests.begin(); i != bodyRequests.end(); ++i )
|
||||
{
|
||||
(*i)->cancel();
|
||||
}
|
||||
}
|
||||
if( stemmedWordFinder.get() ) stemmedWordFinder->cancel();
|
||||
finish();
|
||||
}
|
||||
|
|
|
@ -110,8 +110,8 @@ public:
|
|||
std::vector< sptr< Dictionary::Class > > const & activeDicts,
|
||||
std::string const & header );
|
||||
|
||||
virtual void cancel()
|
||||
{ finish(); } // Add our own requests cancellation here
|
||||
virtual void cancel();
|
||||
// { finish(); } // Add our own requests cancellation here
|
||||
|
||||
private slots:
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ WordFinder::WordFinder( QObject * parent ):
|
|||
updateResultsTimer.setSingleShot( true );
|
||||
|
||||
connect( &updateResultsTimer, SIGNAL( timeout() ),
|
||||
this, SLOT( updateResults() ) );
|
||||
this, SLOT( updateResults() ), Qt::QueuedConnection );
|
||||
}
|
||||
|
||||
WordFinder::~WordFinder()
|
||||
|
|
Loading…
Reference in a new issue