connect(_webView, &WebView::urlCatched, this, &WebFlowCredentialsDialog::urlCatched);
}
+void WebFlowCredentialsDialog::closeEvent(QCloseEvent* e) {
+ Q_UNUSED(e);
+
+ // Force calling WebView::~WebView() earlier so that _profile and _page are
+ // deleted in the correct order.
+ delete _webView;
+}
+
void WebFlowCredentialsDialog::setUrl(const QUrl &url) {
_webView->setUrl(url);
}
void setInfo(const QString &msg);
void setError(const QString &error);
+protected:
+ void closeEvent(QCloseEvent * e) override;
+
signals:
void urlCatched(const QString user, const QString pass, const QString host);
_page->setUrl(url);
}
+WebView::~WebView() {
+ /*
+ * The Qt implmentation deletes children in the order they are added to the
+ * object tree, so in this case _page is deleted after _profile, which
+ * violates the assumption that _profile should exist longer than
+ * _page [1]. Here I delete _page manually so that _profile can be safely
+ * deleted later.
+ *
+ * [1] https://doc.qt.io/qt-5/qwebenginepage.html#QWebEnginePage-1
+ */
+ delete _page;
+}
+
WebViewPageUrlRequestInterceptor::WebViewPageUrlRequestInterceptor(QObject *parent)
: QWebEngineUrlRequestInterceptor(parent) {
Q_OBJECT
public:
WebView(QWidget *parent = nullptr);
+ virtual ~WebView();
void setUrl(const QUrl &url);
signals: