Commit ea13de86 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Merge branch 'Applications/17.04'

parents 39a2be9a b3da1ae8
......@@ -27,19 +27,21 @@
#include <QKeyEvent>
#include <QMouseEvent>
#include <QWheelEvent>
#include <QTimer>
using namespace WebEngineViewer;
class WebEngineViewer::WebEngineViewPrivate
{
public:
WebEngineViewPrivate()
WebEngineViewPrivate(WebEngineView *q)
: mSavedRelativePosition(-1),
mCurrentWidget(nullptr),
mWebEngineNavigatorInterceptor(nullptr),
mWebEngineNavigatorInterceptorView(nullptr),
mPhishingDatabase(nullptr)
mPhishingDatabase(nullptr),
mCrashCount(0),
q(q)
{
}
......@@ -51,20 +53,62 @@ public:
mWebEngineNavigatorInterceptorView = nullptr;
}
void renderProcessTerminated(QWebEnginePage::RenderProcessTerminationStatus status)
{
switch (status) {
case QWebEnginePage::NormalTerminationStatus:
return;
case QWebEnginePage::AbnormalTerminationStatus:
qCInfo(WEBENGINEVIEWER_LOG) << "WebEngine render process terminated abnormally";
break;
case QWebEnginePage::CrashedTerminationStatus:
qCInfo(WEBENGINEVIEWER_LOG) << "WebEngine render process crashed";
break;
case QWebEnginePage::KilledTerminationStatus:
qCInfo(WEBENGINEVIEWER_LOG) << "WebEngine render process killed";
break;
}
// don't get stuck in a loop if the renderer keeps crashing. Five restarts
// is an arbitrary constant.
if (++mCrashCount < 6) {
QTimer::singleShot(0, q, &QWebEngineView::reload);
} else {
// TODO: try to show a sadface page
}
}
qreal mSavedRelativePosition;
QWidget *mCurrentWidget;
WebEngineManageScript *mManagerScript;
WebEngineNavigationRequestInterceptor *mWebEngineNavigatorInterceptor;
WebEngineView *mWebEngineNavigatorInterceptorView;
LocalDataBaseManager *mPhishingDatabase;
int mCrashCount;
private:
WebEngineView * const q;
};
WebEngineView::WebEngineView(QWidget *parent)
: QWebEngineView(parent),
d(new WebEngineViewer::WebEngineViewPrivate)
d(new WebEngineViewer::WebEngineViewPrivate(this))
{
installEventFilter(this);
d->mManagerScript = new WebEngineManageScript(this);
connect(this, &QWebEngineView::renderProcessTerminated,
this, [this](QWebEnginePage::RenderProcessTerminationStatus status) {
d->renderProcessTerminated(status);
});
connect(this, &QWebEngineView::loadFinished,
this, [this]() {
// Reset the crash counter if we manage to actually load a page.
// This does not perfectly correspond to "we managed to render
// a page", but it's the best we have
d->mCrashCount = 0;
});
}
WebEngineView::~WebEngineView()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment