mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-30 21:34:07 +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() ),
|
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,7 +525,12 @@ 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 )
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Loading…
Reference in a new issue