diff options
author | Erik Verbruggen <erik@verbruggen.consulting> | 2021-11-24 17:57:00 +0300 |
---|---|---|
committer | Erik Verbruggen <Erik.Verbruggen@Me.com> | 2021-12-03 12:45:08 +0300 |
commit | ed603153da4fdc385f90982c88660fe0cec2f7ea (patch) | |
tree | 6482e3dae36ef0f0f21b7fcf10c4a06d84fb1604 /src/gui/accountstate.cpp | |
parent | 2aa1922863cb76154befe7ea47245d8c5b4dbb13 (diff) |
Prevent AccountState leak
This happened when an URL is updated (e.g. due to a redirect), and the
user does not accept it.
Diffstat (limited to 'src/gui/accountstate.cpp')
-rw-r--r-- | src/gui/accountstate.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/gui/accountstate.cpp b/src/gui/accountstate.cpp index c9ab14fe2..0243130ec 100644 --- a/src/gui/accountstate.cpp +++ b/src/gui/accountstate.cpp @@ -45,11 +45,13 @@ namespace OCC { Q_LOGGING_CATEGORY(lcAccountState, "gui.account.state", QtInfoMsg) -void AccountState::updateUrlDialog(const QUrl &newUrl) +// Returns the dialog when one is shown, so callers can attach to signals. If no dialog is shown +// (because there is one already, or the new URL matches the current URL), a nullptr is returned. +QDialog *AccountState::updateUrlDialog(const QUrl &newUrl) { // guard to prevent multiple dialogs if (_updateUrlDialog) { - return; + return nullptr; } auto accept = [=] { _account->setUrl(newUrl); @@ -71,7 +73,7 @@ void AccountState::updateUrlDialog(const QUrl &newUrl) if (matchUrl(newUrl, _account->url())) { accept(); - return; + return nullptr; } _updateUrlDialog = new QMessageBox(QMessageBox::Warning, tr("Url update requested for %1").arg(_account->displayName()), @@ -86,6 +88,7 @@ void AccountState::updateUrlDialog(const QUrl &newUrl) } }); _updateUrlDialog->show(); + return _updateUrlDialog; } AccountState::AccountState(AccountPtr account) |