mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-12-17 23:04:06 +00:00
Fix crashes due to deletion resources owned by QNetworkAccessManager
This commit is contained in:
parent
3583ac5b4a
commit
abf027ab70
|
@ -14,19 +14,19 @@ WebMultimediaDownload::WebMultimediaDownload( QUrl const & url,
|
||||||
|
|
||||||
void WebMultimediaDownload::cancel()
|
void WebMultimediaDownload::cancel()
|
||||||
{
|
{
|
||||||
reply.reset();
|
reply = NULL;
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebMultimediaDownload::replyFinished( QNetworkReply * r )
|
void WebMultimediaDownload::replyFinished( QNetworkReply * r )
|
||||||
{
|
{
|
||||||
if ( r != reply.get() )
|
if ( r != reply )
|
||||||
return; // Not our 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 );
|
Mutex::Lock _( dataMutex );
|
||||||
|
|
||||||
|
@ -37,11 +37,11 @@ void WebMultimediaDownload::replyFinished( QNetworkReply * r )
|
||||||
hasAnyData = true;
|
hasAnyData = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
setErrorString( reply->errorString() );
|
setErrorString( r->errorString() );
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
reply.reset();
|
reply = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebMultimediaDownload::isAudioUrl( QUrl const & url )
|
bool WebMultimediaDownload::isAudioUrl( QUrl const & url )
|
||||||
|
|
|
@ -12,7 +12,7 @@ class WebMultimediaDownload: public DataRequest
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
sptr< QNetworkReply > reply;
|
QNetworkReply * reply;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue