mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-30 17: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
|
class MediaWikiArticleRequest: public MediaWikiDataRequestSlots
|
||||||
{
|
{
|
||||||
typedef std::list< std::pair< sptr< QNetworkReply >, bool > > NetReplies;
|
typedef std::list< std::pair< QNetworkReply *, bool > > NetReplies;
|
||||||
NetReplies netReplies;
|
NetReplies netReplies;
|
||||||
QString url;
|
QString url;
|
||||||
|
|
||||||
|
@ -267,12 +267,12 @@ void MediaWikiArticleRequest::addQuery( QNetworkAccessManager & mgr,
|
||||||
|
|
||||||
reqUrl.addQueryItem( "page", gd::toQString( str ) );
|
reqUrl.addQueryItem( "page", gd::toQString( str ) );
|
||||||
|
|
||||||
sptr< QNetworkReply > netReply = mgr.get( QNetworkRequest( reqUrl ) );
|
QNetworkReply * netReply = mgr.get( QNetworkRequest( reqUrl ) );
|
||||||
|
|
||||||
#ifndef QT_NO_OPENSSL
|
#ifndef QT_NO_OPENSSL
|
||||||
|
|
||||||
connect( netReply.get(), SIGNAL( sslErrors( QList< QSslError > ) ),
|
connect( netReply, SIGNAL( sslErrors( QList< QSslError > ) ),
|
||||||
netReply.get(), SLOT( ignoreSslErrors() ) );
|
netReply, SLOT( ignoreSslErrors() ) );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r )
|
||||||
|
|
||||||
for( NetReplies::iterator i = netReplies.begin(); i != netReplies.end(); ++i )
|
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
|
i->second = true; // Mark as finished
|
||||||
found = true;
|
found = true;
|
||||||
|
@ -310,7 +310,7 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r )
|
||||||
|
|
||||||
for( ; netReplies.size() && netReplies.front().second; netReplies.pop_front() )
|
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 )
|
if ( netReply->error() == QNetworkReply::NoError )
|
||||||
{
|
{
|
||||||
|
@ -319,7 +319,7 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r )
|
||||||
QString errorStr;
|
QString errorStr;
|
||||||
int errorLine, errorColumn;
|
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" ).
|
setErrorString( QString( tr( "XML parse error: %1 at %2,%3" ).
|
||||||
arg( errorStr ).arg( errorLine ).arg( errorColumn ) ) );
|
arg( errorStr ).arg( errorLine ).arg( errorColumn ) ) );
|
||||||
|
@ -455,6 +455,8 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
setErrorString( netReply->errorString() );
|
setErrorString( netReply->errorString() );
|
||||||
|
|
||||||
|
netReply->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( netReplies.empty() )
|
if ( netReplies.empty() )
|
||||||
|
|
Loading…
Reference in a new issue