mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
Fix crash at quit while some network queries still active
This commit is contained in:
parent
9a2855f39d
commit
dad18b8113
16
mediawiki.cc
16
mediawiki.cc
|
@ -216,7 +216,7 @@ void MediaWikiWordSearchRequest::downloadFinished()
|
|||
|
||||
class MediaWikiArticleRequest: public MediaWikiDataRequestSlots
|
||||
{
|
||||
typedef std::list< std::pair< sptr< QNetworkReply >, bool > > NetReplies;
|
||||
typedef std::list< std::pair< QNetworkReply *, bool > > NetReplies;
|
||||
NetReplies netReplies;
|
||||
QString url;
|
||||
|
||||
|
@ -267,12 +267,12 @@ void MediaWikiArticleRequest::addQuery( QNetworkAccessManager & mgr,
|
|||
|
||||
reqUrl.addQueryItem( "page", gd::toQString( str ) );
|
||||
|
||||
sptr< QNetworkReply > netReply = mgr.get( QNetworkRequest( reqUrl ) );
|
||||
QNetworkReply * netReply = mgr.get( QNetworkRequest( reqUrl ) );
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
|
||||
connect( netReply.get(), SIGNAL( sslErrors( QList< QSslError > ) ),
|
||||
netReply.get(), SLOT( ignoreSslErrors() ) );
|
||||
connect( netReply, SIGNAL( sslErrors( QList< QSslError > ) ),
|
||||
netReply, SLOT( ignoreSslErrors() ) );
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -292,7 +292,7 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r )
|
|||
|
||||
for( NetReplies::iterator i = netReplies.begin(); i != netReplies.end(); ++i )
|
||||
{
|
||||
if ( i->first.get() == r )
|
||||
if ( i->first == r )
|
||||
{
|
||||
i->second = true; // Mark as finished
|
||||
found = true;
|
||||
|
@ -310,7 +310,7 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r )
|
|||
|
||||
for( ; netReplies.size() && netReplies.front().second; netReplies.pop_front() )
|
||||
{
|
||||
sptr< QNetworkReply > netReply = netReplies.front().first;
|
||||
QNetworkReply * netReply = netReplies.front().first;
|
||||
|
||||
if ( netReply->error() == QNetworkReply::NoError )
|
||||
{
|
||||
|
@ -319,7 +319,7 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r )
|
|||
QString errorStr;
|
||||
int errorLine, errorColumn;
|
||||
|
||||
if ( !dd.setContent( netReply.get(), false, &errorStr, &errorLine, &errorColumn ) )
|
||||
if ( !dd.setContent( netReply, false, &errorStr, &errorLine, &errorColumn ) )
|
||||
{
|
||||
setErrorString( QString( tr( "XML parse error: %1 at %2,%3" ).
|
||||
arg( errorStr ).arg( errorLine ).arg( errorColumn ) ) );
|
||||
|
@ -455,6 +455,8 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r )
|
|||
}
|
||||
else
|
||||
setErrorString( netReply->errorString() );
|
||||
|
||||
netReply->deleteLater();
|
||||
}
|
||||
|
||||
if ( netReplies.empty() )
|
||||
|
|
Loading…
Reference in a new issue