mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-30 17:24:08 +00:00
fix:resource scheme handler received finished signal twice,more likely to crash the webengine.
This commit is contained in:
parent
13fdf08450
commit
be1866db10
|
@ -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 )
|
||||
|
|
|
@ -137,6 +137,8 @@ class ArticleResourceReply: public QNetworkReply
|
|||
sptr< Dictionary::DataRequest > req;
|
||||
qint64 alreadyRead;
|
||||
|
||||
QAtomicInt finishSignalSent;
|
||||
|
||||
public:
|
||||
|
||||
ArticleResourceReply( QObject * parent,
|
||||
|
|
Loading…
Reference in a new issue