diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-05-26 16:15:49 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-05-26 16:15:49 +0200 |
commit | 6938c0cece05fa25c3ce52d0377eba776d0354ff (patch) | |
tree | e335016d99fc7e96ce602ed670674a5b45196510 | |
parent | Profile command (diff) | |
download | smolbote-6938c0cece05fa25c3ce52d0377eba776d0354ff.tar.xz |
QTBUG-68224 workaround
-rw-r--r-- | BUGS.md | 5 | ||||
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/webengine/webpage.cpp | 29 | ||||
-rw-r--r-- | src/webengine/webpage.h | 1 |
4 files changed, 36 insertions, 0 deletions
@@ -35,3 +35,8 @@ https://bugreports.qt.io/browse/QTBUG-62957 ### loadFinished is not always emitted when loading is finished https://bugreports.qt.io/browse/QTBUG-65223 + +### QWebEngineView setUrl()/load() methods in some case divide page in two parts +https://bugreports.qt.io/browse/QTBUG-68224 + +Only affects Qt 5.11.0. Set __QTBUG_68224_WORKAROUND__. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 44823df..c326c4b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -63,6 +63,7 @@ target_link_libraries(poi target_compile_definitions(poi PRIVATE QTBUG_65223_WORKAROUND + PRIVATE QTBUG_68224_WORKAROUND ) install(TARGETS poi RUNTIME DESTINATION bin CONFIGURATIONS Release) diff --git a/src/webengine/webpage.cpp b/src/webengine/webpage.cpp index fe011b4..6fba97c 100644 --- a/src/webengine/webpage.cpp +++ b/src/webengine/webpage.cpp @@ -10,6 +10,8 @@ #include <QMessageBox> #include <QWebEngineFullScreenRequest> +#include <QLayout> + QString feature_toString(QWebEnginePage::Feature feature) { switch(feature) { @@ -70,6 +72,33 @@ bool WebPage::certificateError(const QWebEngineCertificateError &certificateErro return resp == QMessageBox::Ignore; } +bool WebPage::acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) +{ + + /* Workaround for https://bugreports.qt.io/browse/QTBUG-68224 + * Only affects 5.11.0; should be fixed in 5.11.1 + */ +#ifdef QTBUG_68224_WORKAROUND + auto *layout = this->view()->layout(); + auto count = layout->count(); + + if(count > 1) { + for (int i = 0; i < count; ++i) { + auto *item = layout->itemAt(i); + if(item == nullptr) + continue; + auto *widget = item->widget(); + if(widget != this->view()->focusProxy()) { + //qDebug("Removing widget"); + layout->removeWidget(widget); + } + } + } +#endif + + return true; +} + void WebPage::featurePermissionDialog(const QUrl &securityOrigin, QWebEnginePage::Feature feature) { QMessageBox messageBox; diff --git a/src/webengine/webpage.h b/src/webengine/webpage.h index 92c5925..2232d26 100644 --- a/src/webengine/webpage.h +++ b/src/webengine/webpage.h @@ -19,6 +19,7 @@ public: protected: bool certificateError(const QWebEngineCertificateError &certificateError) override; + bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) override; private slots: void featurePermissionDialog(const QUrl &securityOrigin, QWebEnginePage::Feature feature); |