From 8e16efc1bfc818a33d4d149799c53a988e0227f6 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Sat, 8 Apr 2017 16:44:41 +0200 Subject: [PATCH] Fix crash when restoring history of internal pages with QtWebEngine 5.8 Closes #2302 --- src/lib/webengine/webview.cpp | 6 ------ src/lib/webengine/webview.h | 2 -- src/lib/webtab/webtab.cpp | 18 ++++++++++++------ src/lib/webtab/webtab.h | 1 - 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/lib/webengine/webview.cpp b/src/lib/webengine/webview.cpp index 7f71aa90d..8cb659c8e 100644 --- a/src/lib/webengine/webview.cpp +++ b/src/lib/webengine/webview.cpp @@ -258,12 +258,6 @@ QRect WebView::scrollBarGeometry(Qt::Orientation orientation) const return s && s->isVisible() ? s->geometry() : QRect(); } -void WebView::restoreHistory(const QByteArray &data) -{ - QDataStream stream(data); - stream >> *history(); -} - QWidget *WebView::inputWidget() const { return m_rwhvqt ? m_rwhvqt : const_cast(this); diff --git a/src/lib/webengine/webview.h b/src/lib/webengine/webview.h index d74dedd15..0b1920f26 100644 --- a/src/lib/webengine/webview.h +++ b/src/lib/webengine/webview.h @@ -60,8 +60,6 @@ public: QPointF mapToViewport(const QPointF &pos) const; QRect scrollBarGeometry(Qt::Orientation orientation) const; - void restoreHistory(const QByteArray &data); - void addNotification(QWidget* notif); bool eventFilter(QObject *obj, QEvent *event); diff --git a/src/lib/webtab/webtab.cpp b/src/lib/webtab/webtab.cpp index ed9be4373..3e63da4d9 100644 --- a/src/lib/webtab/webtab.cpp +++ b/src/lib/webtab/webtab.cpp @@ -300,11 +300,6 @@ void WebTab::attach(BrowserWindow* window) m_tabIcon->updateIcon(); } -void WebTab::setHistoryData(const QByteArray &data) -{ - m_webView->restoreHistory(data); -} - QByteArray WebTab::historyData() const { if (isRestored()) { @@ -413,7 +408,18 @@ void WebTab::restoreTab(const WebTab::SavedTab &tab) void WebTab::p_restoreTab(const QUrl &url, const QByteArray &history, int zoomLevel) { m_webView->load(url); - m_webView->restoreHistory(history); + + // Restoring history of internal pages crashes QtWebEngine 5.8 + static const QStringList blacklistedSchemes = { + QSL("view-source"), + QSL("chrome") + }; + + if (!blacklistedSchemes.contains(url.scheme())) { + QDataStream stream(history); + stream >> *m_webView->history(); + } + m_webView->setZoomLevel(zoomLevel); m_webView->setFocus(); } diff --git a/src/lib/webtab/webtab.h b/src/lib/webtab/webtab.h index a39f57592..b08dbc617 100644 --- a/src/lib/webtab/webtab.h +++ b/src/lib/webtab/webtab.h @@ -73,7 +73,6 @@ public: void detach(); void attach(BrowserWindow* window); - void setHistoryData(const QByteArray &data); QByteArray historyData() const; void stop();