From e7316c9fe781e15a195d1cfe77b777ec92eaee4c Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 29 Jan 2018 10:22:47 +0100 Subject: 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 --- src/plugins/help/webenginehelpviewer.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/plugins/help/webenginehelpviewer.cpp') 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 #include #include +#include #include #if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) #include @@ -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); -- cgit v1.2.1