mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
fix: resource scheme handler received finished signal twice,more likely to crash the webengine.
This commit is contained in:
parent
f16107e072
commit
bd6cc8b9c9
|
@ -438,8 +438,6 @@ ArticleResourceReply::ArticleResourceReply( QObject * parent,
|
|||
{
|
||||
connect( this, SIGNAL( readyReadSignal() ),
|
||||
this, SLOT( readyReadSlot() ), Qt::QueuedConnection );
|
||||
connect( this, SIGNAL( finishedSignal() ),
|
||||
this, SLOT( finishedSlot() ), Qt::QueuedConnection );
|
||||
|
||||
emit readyReadSignal();
|
||||
|
||||
|
@ -448,6 +446,10 @@ ArticleResourceReply::ArticleResourceReply( QObject * parent,
|
|||
emit finishedSignal();
|
||||
GD_DPRINTF( "In-place finish.\n" );
|
||||
}
|
||||
else{
|
||||
connect( this, SIGNAL( finishedSignal() ),
|
||||
this, SLOT( finishedSlot() ), Qt::QueuedConnection );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
#ifndef GICO_SCHEMAHANDLER_H
|
||||
#define GICO_SCHEMAHANDLER_H
|
||||
|
||||
#include"article_netmgr.hh"
|
||||
|
||||
class GicoSchemeHandler : public QWebEngineUrlSchemeHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
GicoSchemeHandler(ArticleNetworkAccessManager& articleNetMgr);
|
||||
void requestStarted(QWebEngineUrlRequestJob *requestJob);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
ArticleNetworkAccessManager& mManager;
|
||||
QMimeDatabase db;
|
||||
};
|
||||
|
||||
#endif // GICO_SCHEMAHANDLER_H
|
|
@ -247,11 +247,11 @@ DEFINES += PROGRAM_VERSION=\\\"$$VERSION\\\"
|
|||
|
||||
# Input
|
||||
HEADERS += folding.hh \
|
||||
gico_schemahandler.h \
|
||||
globalbroadcaster.h \
|
||||
inc_case_folding.hh \
|
||||
inc_diacritic_folding.hh \
|
||||
mainwindow.hh \
|
||||
resourceschemehandler.h \
|
||||
sptr.hh \
|
||||
dictionary.hh \
|
||||
ex.hh \
|
||||
|
@ -388,11 +388,11 @@ FORMS += groups.ui \
|
|||
fulltextsearch.ui
|
||||
|
||||
SOURCES += folding.cc \
|
||||
gico_schemahandler.cpp \
|
||||
globalbroadcaster.cpp \
|
||||
main.cc \
|
||||
dictionary.cc \
|
||||
config.cc \
|
||||
resourceschemehandler.cpp \
|
||||
sources.cc \
|
||||
mainwindow.cc \
|
||||
utf8.cc \
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#include "utils.hh"
|
||||
#include <QDesktopWidget>
|
||||
#include "ui_authentication.h"
|
||||
#include "gico_schemahandler.h"
|
||||
#include "resourceschemehandler.h"
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#include "lionsupport.h"
|
||||
|
@ -146,14 +146,14 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
|||
#endif
|
||||
|
||||
|
||||
LocalSchemeHandler *handler = new LocalSchemeHandler(articleNetMgr);
|
||||
QWebEngineProfile::defaultProfile()->installUrlSchemeHandler("gdlookup", handler);
|
||||
QWebEngineProfile::defaultProfile()->installUrlSchemeHandler("bword", handler);
|
||||
localSchemeHandler = new LocalSchemeHandler(articleNetMgr);
|
||||
QWebEngineProfile::defaultProfile()->installUrlSchemeHandler("gdlookup", localSchemeHandler);
|
||||
QWebEngineProfile::defaultProfile()->installUrlSchemeHandler("bword", localSchemeHandler);
|
||||
|
||||
QStringList localSchemes={"gdau","gico","qrcx","bres","gdprg","gdvideo","gdpicture","gdtts"};
|
||||
GicoSchemeHandler *h=new GicoSchemeHandler(articleNetMgr);
|
||||
resourceSchemeHandler = new ResourceSchemeHandler(articleNetMgr);
|
||||
for(int i=0;i<localSchemes.size();i++){
|
||||
QWebEngineProfile::defaultProfile()->installUrlSchemeHandler(localSchemes.at(i).toLatin1(), h);
|
||||
QWebEngineProfile::defaultProfile()->installUrlSchemeHandler(localSchemes.at(i).toLatin1(), resourceSchemeHandler);
|
||||
}
|
||||
|
||||
wuri = new WebUrlRequestInterceptor();
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include "hotkeywrapper.hh"
|
||||
#include "weburlrequestinterceptor.h"
|
||||
#include "resourceschemehandler.h"
|
||||
#ifdef HAVE_X11
|
||||
#include <fixx11h.h>
|
||||
#endif
|
||||
|
@ -194,6 +195,9 @@ private:
|
|||
|
||||
QIcon starIcon, blueStarIcon;
|
||||
|
||||
LocalSchemeHandler *localSchemeHandler;
|
||||
ResourceSchemeHandler *resourceSchemeHandler;
|
||||
|
||||
/// Applies the qt's stylesheet, given the style's name.
|
||||
void applyQtStyleSheet( QString const & displayStyle, QString const & addonStyle );
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include "gico_schemahandler.h"
|
||||
#include "resourceschemehandler.h"
|
||||
|
||||
GicoSchemeHandler::GicoSchemeHandler(ArticleNetworkAccessManager& articleNetMgr):mManager(articleNetMgr){
|
||||
ResourceSchemeHandler::ResourceSchemeHandler(ArticleNetworkAccessManager& articleNetMgr):mManager(articleNetMgr){
|
||||
|
||||
}
|
||||
void GicoSchemeHandler::requestStarted(QWebEngineUrlRequestJob *requestJob)
|
||||
void ResourceSchemeHandler::requestStarted(QWebEngineUrlRequestJob *requestJob)
|
||||
{
|
||||
QUrl url = requestJob->requestUrl();
|
||||
|
||||
|
@ -17,7 +17,7 @@ void GicoSchemeHandler::requestStarted(QWebEngineUrlRequestJob *requestJob)
|
|||
requestJob->fail(QWebEngineUrlRequestJob::UrlNotFound);
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "resource scheme handler receive finished signal:" << reply->request().url();
|
||||
QMimeType mineType = db.mimeTypeForUrl(url);
|
||||
QString contentType = mineType.name();
|
||||
// Reply segment
|
20
resourceschemehandler.h
Normal file
20
resourceschemehandler.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef RESOURCESCHEMEHANDLER_H
|
||||
#define RESOURCESCHEMEHANDLER_H
|
||||
|
||||
#include"article_netmgr.hh"
|
||||
|
||||
class ResourceSchemeHandler : public QWebEngineUrlSchemeHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ResourceSchemeHandler(ArticleNetworkAccessManager& articleNetMgr);
|
||||
void requestStarted(QWebEngineUrlRequestJob *requestJob);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
ArticleNetworkAccessManager& mManager;
|
||||
QMimeDatabase db;
|
||||
};
|
||||
|
||||
#endif // RESOURCESCHEMEHANDLER_H
|
Loading…
Reference in a new issue