mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 23:34:06 +00:00
Merge pull request #301 from timonwong/master
Fix crashes due to deletion resources owned by QNetworkAccessManager
This commit is contained in:
commit
986a3e027a
|
@ -14,19 +14,19 @@ WebMultimediaDownload::WebMultimediaDownload( QUrl const & url,
|
|||
|
||||
void WebMultimediaDownload::cancel()
|
||||
{
|
||||
reply.reset();
|
||||
reply = NULL;
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
void WebMultimediaDownload::replyFinished( QNetworkReply * r )
|
||||
{
|
||||
if ( r != reply.get() )
|
||||
if ( !r || r != reply )
|
||||
return; // Not our reply
|
||||
|
||||
if ( reply->error() == QNetworkReply::NoError )
|
||||
if ( r->error() == QNetworkReply::NoError )
|
||||
{
|
||||
QByteArray all = reply->readAll();
|
||||
QByteArray all = r->readAll();
|
||||
|
||||
Mutex::Lock _( dataMutex );
|
||||
|
||||
|
@ -37,11 +37,12 @@ void WebMultimediaDownload::replyFinished( QNetworkReply * r )
|
|||
hasAnyData = true;
|
||||
}
|
||||
else
|
||||
setErrorString( reply->errorString() );
|
||||
setErrorString( r->errorString() );
|
||||
|
||||
r->deleteLater();
|
||||
reply = NULL;
|
||||
|
||||
finish();
|
||||
|
||||
reply.reset();
|
||||
}
|
||||
|
||||
bool WebMultimediaDownload::isAudioUrl( QUrl const & url )
|
||||
|
|
|
@ -12,7 +12,7 @@ class WebMultimediaDownload: public DataRequest
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
sptr< QNetworkReply > reply;
|
||||
QNetworkReply * reply;
|
||||
|
||||
public:
|
||||
|
||||
|
|
Loading…
Reference in a new issue