summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2018-01-29 10:22:47 +0100
committerEike Ziller <eike.ziller@qt.io>2018-02-01 12:08:37 +0000
commite7316c9fe781e15a195d1cfe77b777ec92eaee4c (patch)
treebaec8de5c2a487b0a71c8e9b0620f078d18e2d27
parentd3f5f63a332e4cf4b98ef64dcd5352de86962d0b (diff)
downloadqt-creator-e7316c9fe781e15a195d1cfe77b777ec92eaee4c.tar.gz
Help: Workaround overrideCursor issue with WebEngine based viewer
QWebEngineViewer never sends a loadFinished signal (but a loadStarted signal) when only the URL fragment changes (QTBUG-65223). Work around by logging the last URL and recognizing that condition. Task-number: QTCREATORBUG-19649 Change-Id: I7b96fe60f5c76ebffb36c23e8d62c6cb1aa515aa Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
-rw-r--r--src/plugins/help/webenginehelpviewer.cpp16
-rw-r--r--src/plugins/help/webenginehelpviewer.h1
2 files changed, 16 insertions, 1 deletions
diff --git a/src/plugins/help/webenginehelpviewer.cpp b/src/plugins/help/webenginehelpviewer.cpp
index 9ff0b1965a..18c4d865d4 100644
--- a/src/plugins/help/webenginehelpviewer.cpp
+++ b/src/plugins/help/webenginehelpviewer.cpp
@@ -34,6 +34,7 @@
#include <QBuffer>
#include <QContextMenuEvent>
#include <QCoreApplication>
+#include <QTimer>
#include <QVBoxLayout>
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
#include <QWebEngineContextMenuData>
@@ -89,7 +90,20 @@ WebEngineHelpViewer::WebEngineHelpViewer(QWidget *parent) :
setPalette(p);
connect(m_widget, &QWebEngineView::urlChanged, this, &WebEngineHelpViewer::sourceChanged);
- connect(m_widget, &QWebEngineView::loadStarted, this, &WebEngineHelpViewer::slotLoadStarted);
+ connect(m_widget, &QWebEngineView::loadStarted, this, [this] {
+ slotLoadStarted();
+ // Work around QTBUG-65223: if only anchor changed, we never get a loadFinished signal
+ // If a link is clicked in a page, it can happen that the new URL has not yet been set,
+ // so we need to delay a bit...
+ QTimer::singleShot(/*magic timeout=*/150, this, [this] {
+ QUrl urlWithoutFragment = source();
+ urlWithoutFragment.setFragment(QString());
+ qDebug() << urlWithoutFragment << m_previousUrlWithoutFragment;
+ if (urlWithoutFragment == m_previousUrlWithoutFragment)
+ slotLoadFinished();
+ m_previousUrlWithoutFragment = urlWithoutFragment;
+ });
+ });
connect(m_widget, &QWebEngineView::loadFinished, this, &WebEngineHelpViewer::slotLoadFinished);
connect(m_widget, &QWebEngineView::titleChanged, this, &WebEngineHelpViewer::titleChanged);
connect(m_widget->page(), &QWebEnginePage::linkHovered, this, &WebEngineHelpViewer::setToolTip);
diff --git a/src/plugins/help/webenginehelpviewer.h b/src/plugins/help/webenginehelpviewer.h
index d5835c4d6a..390e90ea65 100644
--- a/src/plugins/help/webenginehelpviewer.h
+++ b/src/plugins/help/webenginehelpviewer.h
@@ -97,6 +97,7 @@ public:
private:
WebView *m_widget;
+ QUrl m_previousUrlWithoutFragment;
};
} // namespace Internal