fix:resource scheme handler received finished signal twice,more likely to crash the webengine.

This commit is contained in:
xiaoyifang 2022-01-09 14:30:06 +08:00
parent 13fdf08450
commit be1866db10
2 changed files with 10 additions and 5 deletions

View file

@ -438,6 +438,8 @@ ArticleResourceReply::ArticleResourceReply( QObject * parent,
{ {
connect( this, SIGNAL( readyReadSignal() ), connect( this, SIGNAL( readyReadSignal() ),
this, SLOT( readyReadSlot() ), Qt::QueuedConnection ); this, SLOT( readyReadSlot() ), Qt::QueuedConnection );
connect( this, SIGNAL( finishedSignal() ),
this, SLOT( finishedSlot() ), Qt::QueuedConnection );
emit readyReadSignal(); emit readyReadSignal();
@ -446,10 +448,6 @@ ArticleResourceReply::ArticleResourceReply( QObject * parent,
emit finishedSignal(); emit finishedSignal();
GD_DPRINTF( "In-place finish.\n" ); GD_DPRINTF( "In-place finish.\n" );
} }
else{
connect( this, SIGNAL( finishedSignal() ),
this, SLOT( finishedSlot() ), Qt::QueuedConnection );
}
} }
} }
@ -527,8 +525,13 @@ void ArticleResourceReply::finishedSlot()
setError(ContentNotFoundError, "content not found"); setError(ContentNotFoundError, "content not found");
} }
//prevent sent multi times.
if (!finishSignalSent.loadAcquire())
{
finishSignalSent.ref();
emit finished(); emit finished();
} }
}
BlockedNetworkReply::BlockedNetworkReply( QObject * parent ): QNetworkReply( parent ) BlockedNetworkReply::BlockedNetworkReply( QObject * parent ): QNetworkReply( parent )
{ {

View file

@ -137,6 +137,8 @@ class ArticleResourceReply: public QNetworkReply
sptr< Dictionary::DataRequest > req; sptr< Dictionary::DataRequest > req;
qint64 alreadyRead; qint64 alreadyRead;
QAtomicInt finishSignalSent;
public: public:
ArticleResourceReply( QObject * parent, ArticleResourceReply( QObject * parent,