Changeset View
Changeset View
Standalone View
Standalone View
files/fix-login-crash.patch
- This file was added.
| From 09b0055dc3fe8ffae64dae7af9f522ed12ebdea8 Mon Sep 17 00:00:00 2001 | |||||
| From: Chih-Hsuan Yen <yen@chyen.cc> | |||||
| Date: Wed, 19 Dec 2018 21:44:54 +0800 | |||||
| Subject: [PATCH] Make sure _profile and _page are deleted in the correct order | |||||
| Inspired by https://github.com/electron/electron/pull/15028 | |||||
| Closes https://github.com/nextcloud/desktop/issues/941 | |||||
| Closes https://github.com/nextcloud/desktop/issues/950 | |||||
| --- | |||||
| src/gui/creds/webflowcredentialsdialog.cpp | 8 ++++++++ | |||||
| src/gui/creds/webflowcredentialsdialog.h | 3 +++ | |||||
| src/gui/wizard/webview.cpp | 13 +++++++++++++ | |||||
| src/gui/wizard/webview.h | 1 + | |||||
| 4 files changed, 25 insertions(+) | |||||
| diff --git a/src/gui/creds/webflowcredentialsdialog.cpp b/src/gui/creds/webflowcredentialsdialog.cpp | |||||
| index 85dd87451..2d22ba06e 100644 | |||||
| --- a/src/gui/creds/webflowcredentialsdialog.cpp | |||||
| +++ b/src/gui/creds/webflowcredentialsdialog.cpp | |||||
| @@ -29,6 +29,14 @@ WebFlowCredentialsDialog::WebFlowCredentialsDialog(QWidget *parent) | |||||
| 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); | |||||
| } | |||||
| diff --git a/src/gui/creds/webflowcredentialsdialog.h b/src/gui/creds/webflowcredentialsdialog.h | |||||
| index 84ed4ea12..9849ee3a4 100644 | |||||
| --- a/src/gui/creds/webflowcredentialsdialog.h | |||||
| +++ b/src/gui/creds/webflowcredentialsdialog.h | |||||
| @@ -21,6 +21,9 @@ class WebFlowCredentialsDialog : public QDialog | |||||
| 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); | |||||
| diff --git a/src/gui/wizard/webview.cpp b/src/gui/wizard/webview.cpp | |||||
| index 1c6a74363..929b61205 100644 | |||||
| --- a/src/gui/wizard/webview.cpp | |||||
| +++ b/src/gui/wizard/webview.cpp | |||||
| @@ -105,6 +105,19 @@ void WebView::setUrl(const QUrl &url) { | |||||
| _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) { | |||||
| diff --git a/src/gui/wizard/webview.h b/src/gui/wizard/webview.h | |||||
| index e0b93ec84..93baf6b59 100644 | |||||
| --- a/src/gui/wizard/webview.h | |||||
| +++ b/src/gui/wizard/webview.h | |||||
| @@ -21,6 +21,7 @@ class WebView : public QWidget | |||||
| Q_OBJECT | |||||
| public: | |||||
| WebView(QWidget *parent = nullptr); | |||||
| + virtual ~WebView(); | |||||
| void setUrl(const QUrl &url); | |||||
| signals: | |||||
Copyright © 2015-2021 Solus Project. The Solus logo is Copyright © 2016-2021 Solus Project. All Rights Reserved.