Commit b5ee6ff1 authored by Krzysztof Nowicki's avatar Krzysztof Nowicki
Browse files

resources/ews: Fix saving passwords to KWallet

This is a regression after switching to asynchronous wallet
opening. When saving the password the wallet is opened and a callback is
registered to write the password once the wallet is ready. Unfortunately
all this is done in an instance of the EwsSettings class that is local
to the configuration dialog class. This means that this instance is
destroyed once the configuration dialog is dismissed, so when opening
the wallet takes a split second too long the object dies before the
callback has a chance to do its job.

The fix is not to use a local instance of the EwsSettings class in the
configuration dialog and instead work on a pointer to this object kept
by the root resource class, which is alive at all times.

BUG: 393002
parent 8b04a8f5
......@@ -48,10 +48,11 @@ static const QVector<StringPair> userAgents = {
{QStringLiteral("Mozilla Thunderbird 38 for Mac (with ExQuilla)"), QStringLiteral("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:38.0) Gecko/20100101 Thunderbird/38.2.0")}
EwsConfigDialog::EwsConfigDialog(EwsResource *parentResource, EwsClient &client, WId wId)
EwsConfigDialog::EwsConfigDialog(EwsResource *parentResource, EwsClient &client, WId wId,
EwsSettings *settings)
: QDialog()
, mParentResource(parentResource)
, mSettings(new EwsSettings(wId))
, mSettings(settings)
if (wId) {
KWindowSystem::setMainWindow(this, wId);
......@@ -21,6 +21,7 @@
#include <QDialog>
#include <QPointer>
class QDialogButtonBox;
......@@ -42,7 +43,8 @@ class EwsConfigDialog : public QDialog
explicit EwsConfigDialog(EwsResource *parentResource, EwsClient &client, WId windowId);
explicit EwsConfigDialog(EwsResource *parentResource, EwsClient &client, WId windowId,
EwsSettings *settings);
~EwsConfigDialog() override;
void save();
......@@ -70,7 +72,7 @@ private:
bool mTryConnectNeeded = false;
EwsProgressDialog *mProgressDialog = nullptr;
EwsSubscriptionWidget *mSubWidget = nullptr;
QScopedPointer<EwsSettings> mSettings;
QPointer<EwsSettings> mSettings;
......@@ -472,7 +472,7 @@ void EwsResource::passwordRequestFinished(const QString &password)
void EwsResource::configure(WId windowId)
QPointer<EwsConfigDialog> dlg = new EwsConfigDialog(this, mEwsClient, windowId);
QPointer<EwsConfigDialog> dlg = new EwsConfigDialog(this, mEwsClient, windowId,;
if (dlg->exec()) {
Q_EMIT configurationDialogAccepted();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment