diff options
author | Eike Ziller <[email protected]> | 2018-01-29 10:22:47 +0100 |
---|---|---|
committer | Eike Ziller <[email protected]> | 2018-02-01 12:08:37 +0000 |
commit | e7316c9fe781e15a195d1cfe77b777ec92eaee4c (patch) | |
tree | baec8de5c2a487b0a71c8e9b0620f078d18e2d27 /src/plugins/help/webenginehelpviewer.cpp | |
parent | d3f5f63a332e4cf4b98ef64dcd5352de86962d0b (diff) |
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 <[email protected]>
Diffstat (limited to 'src/plugins/help/webenginehelpviewer.cpp')
-rw-r--r-- | src/plugins/help/webenginehelpviewer.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/plugins/help/webenginehelpviewer.cpp b/src/plugins/help/webenginehelpviewer.cpp index 9ff0b1965ab..18c4d865d41 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); |