Changeset View
Standalone View
src/articleviewer-ng/webengine/articleviewerwebengine.cpp
Show All 40 Lines | |||||
41 | #include <KMessageBox> | 41 | #include <KMessageBox> | ||
42 | #include <QPrinter> | 42 | #include <QPrinter> | ||
43 | #include <QMouseEvent> | 43 | #include <QMouseEvent> | ||
44 | #include <QApplication> | 44 | #include <QApplication> | ||
45 | #include <QClipboard> | 45 | #include <QClipboard> | ||
46 | #include <QMenu> | 46 | #include <QMenu> | ||
47 | #include <viewerplugintoolmanager.h> | 47 | #include <viewerplugintoolmanager.h> | ||
48 | #include <QWebEngineProfile> | 48 | #include <QWebEngineProfile> | ||
49 | #include <QWebEngineUrlRequestInterceptor> | ||||
49 | 50 | | |||
50 | #include <WebEngineViewer/WebHitTestResult> | 51 | #include <WebEngineViewer/WebHitTestResult> | ||
51 | #include <WebEngineViewer/WebHitTest> | 52 | #include <WebEngineViewer/WebHitTest> | ||
52 | #include <WebEngineViewer/WebEngineScript> | 53 | #include <WebEngineViewer/WebEngineScript> | ||
53 | 54 | | |||
54 | #include <WebEngineViewer/LocalDataBaseManager> | 55 | #include <WebEngineViewer/LocalDataBaseManager> | ||
55 | | ||||
56 | #include <KIO/KUriFilterSearchProviderActions> | 56 | #include <KIO/KUriFilterSearchProviderActions> | ||
57 | 57 | | |||
58 | using namespace Akregator; | 58 | using namespace Akregator; | ||
59 | 59 | | |||
60 | | ||||
61 | class AkregatorRequestInterceptor : public QWebEngineUrlRequestInterceptor | ||||
62 | { | ||||
63 | Q_OBJECT | ||||
64 | | ||||
65 | public: | ||||
66 | explicit AkregatorRequestInterceptor(QObject *parent = nullptr) : QWebEngineUrlRequestInterceptor(parent) { | ||||
67 | } | ||||
mlaurent: ~AkregatorRequestInterceptor() override = default(); no ? | |||||
Is there any point in using 'override' on destructors? There is no function signature to trigger the usual warning case (derived class defines a function with a different signature, so not really replacing the base class virtual), so there is no way a destructor can be written to not override. The compiler doesn't consider destructors in its override warning. The only way in which 'override' would be useful on a destructor would be to give an error if the base class destructor was not declared virtual, but with a correctly written base class this should not arise. marten: Is there any point in using 'override' on destructors? There is no function signature to… | |||||
amantia: I removed the destructor completely. | |||||
Sorry for getting more off-topic, but /me wants to clarify this:
Right, and why not protect against this? I think adding an override to dtors makes a lot of sense. Especially if you think of override as of: "I expect there to exist a base class version of this function which is declared virtual". Also see discussion on qt-development: https://lists.qt-project.org/pipermail/development/2018-August/033437.html kfunk: Sorry for getting more off-topic, but /me wants to clarify this:
> The only way in which… | |||||
68 | virtual ~AkregatorRequestInterceptor() = default; | ||||
69 | | ||||
70 | void interceptRequest(QWebEngineUrlRequestInfo &info) { | ||||
71 | Q_UNUSED(info); | ||||
72 | } | ||||
73 | }; | ||||
74 | | ||||
75 | | ||||
60 | ArticleViewerWebEngine::ArticleViewerWebEngine(KActionCollection *ac, QWidget *parent) | 76 | ArticleViewerWebEngine::ArticleViewerWebEngine(KActionCollection *ac, QWidget *parent) | ||
61 | : WebEngineViewer::WebEngineView(parent) | 77 | : WebEngineViewer::WebEngineView(parent) | ||
62 | , mActionCollection(ac) | 78 | , mActionCollection(ac) | ||
63 | , mLastButtonClicked(LeftButton) | 79 | , mLastButtonClicked(LeftButton) | ||
64 | , mViewerPluginToolManager(nullptr) | 80 | , mViewerPluginToolManager(nullptr) | ||
65 | { | 81 | { | ||
66 | mNetworkAccessManager = new WebEngineViewer::InterceptorManager(this, ac, this); | 82 | mNetworkAccessManager = new WebEngineViewer::InterceptorManager(this, ac, this); | ||
83 | mWebEngineUrlInterceptor = new AkregatorRequestInterceptor(); | ||||
kfunk: Note: You dont actually need a member at all here, no? | |||||
amantia: Right, it is possible without it as well. | |||||
84 | | ||||
67 | QWebEngineProfile *profile = QWebEngineProfile::defaultProfile(); | 85 | QWebEngineProfile *profile = QWebEngineProfile::defaultProfile(); | ||
68 | mPageEngine = new ArticleViewerWebEnginePage(profile, this); | 86 | mPageEngine = new ArticleViewerWebEnginePage(profile, this); | ||
69 | profile->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies); | 87 | profile->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies); | ||
70 | 88 | | |||
89 | // Needed to workaround crash in webengine, see https://bugreports.qt.io/browse/QTBUG-72260 | ||||
90 | profile->setRequestInterceptor(mWebEngineUrlInterceptor); | ||||
91 | connect(profile, &QObject::destroyed, mWebEngineUrlInterceptor, [this] { | ||||
92 | mWebEngineUrlInterceptor->deleteLater(); | ||||
93 | }); | ||||
94 | | ||||
71 | setPage(mPageEngine); | 95 | setPage(mPageEngine); | ||
72 | 96 | | |||
73 | connect(this, &ArticleViewerWebEngine::showContextMenu, this, &ArticleViewerWebEngine::slotShowContextMenu); | 97 | connect(this, &ArticleViewerWebEngine::showContextMenu, this, &ArticleViewerWebEngine::slotShowContextMenu); | ||
74 | 98 | | |||
75 | setFocusPolicy(Qt::WheelFocus); | 99 | setFocusPolicy(Qt::WheelFocus); | ||
76 | connect(mPageEngine, &ArticleViewerWebEnginePage::urlClicked, this, &ArticleViewerWebEngine::slotLinkClicked); | 100 | connect(mPageEngine, &ArticleViewerWebEnginePage::urlClicked, this, &ArticleViewerWebEngine::slotLinkClicked); | ||
77 | 101 | | |||
78 | mWebEngineViewAccessKey = new WebEngineViewer::WebEngineAccessKey(this, this); | 102 | mWebEngineViewAccessKey = new WebEngineViewer::WebEngineAccessKey(this, this); | ||
▲ Show 20 Lines • Show All 410 Lines • ▼ Show 20 Line(s) | |||||
489 | { | 513 | { | ||
490 | const QString text = selectedText(); | 514 | const QString text = selectedText(); | ||
491 | if (!text.isEmpty()) { | 515 | if (!text.isEmpty()) { | ||
492 | interface->setText(text); | 516 | interface->setText(text); | ||
493 | } | 517 | } | ||
494 | interface->setUrl(mCurrentUrl); | 518 | interface->setUrl(mCurrentUrl); | ||
495 | interface->execute(); | 519 | interface->execute(); | ||
496 | } | 520 | } | ||
521 | | ||||
522 | #include "articleviewerwebengine.moc" |
~AkregatorRequestInterceptor() override = default(); no ?