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

View file

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