Verified Commit 2b68edaf authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

IMAP: don't block when displaying the Subscription dialog

Summary:
The configureSubscription() slot is invoked via DBus, so using QDialog::exec
to display the dialog may cause the DBus call to time out, leading to a
suspicous warning printed by KMail ("invalid reply").

Reviewers: winterz, #kde_pim

Reviewed By: winterz, #kde_pim

Subscribers: kde-pim

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D27775
parent 93ecfacf
......@@ -98,7 +98,6 @@ ImapResourceBase::ImapResourceBase(const QString &id)
: ResourceBase(id)
, m_pool(new SessionPool(2, this))
, m_settings(nullptr)
, mSubscriptions(nullptr)
, m_idle(nullptr)
{
QTimer::singleShot(0, this, &ImapResourceBase::updateResourceName);
......@@ -262,7 +261,7 @@ int ImapResourceBase::configureSubscription(qlonglong windowId)
return -1;
}
mSubscriptions = new SubscriptionDialog(nullptr, SubscriptionDialog::AllowToEnableSubscription);
mSubscriptions.reset(new SubscriptionDialog(nullptr, SubscriptionDialog::AllowToEnableSubscription));
if (windowId) {
mSubscriptions->setAttribute(Qt::WA_NativeWindow, true);
KWindowSystem::setMainWindow(mSubscriptions->windowHandle(), windowId);
......@@ -271,14 +270,18 @@ int ImapResourceBase::configureSubscription(qlonglong windowId)
mSubscriptions->setWindowIcon(QIcon::fromTheme(QStringLiteral("network-server")));
mSubscriptions->connectAccount(*m_pool->account(), password);
mSubscriptions->setSubscriptionEnabled(settings()->subscriptionEnabled());
if (mSubscriptions->exec()) {
settings()->setSubscriptionEnabled(mSubscriptions->subscriptionEnabled());
settings()->save();
Q_EMIT configurationDialogAccepted();
reconnect();
}
delete mSubscriptions;
connect(mSubscriptions.get(), &SubscriptionDialog::accepted,
this, [this]() {
settings()->setSubscriptionEnabled(mSubscriptions->subscriptionEnabled());
settings()->save();
Q_EMIT configurationDialogAccepted();
reconnect();
});
connect(mSubscriptions.get(), &SubscriptionDialog::finished,
this, [this]() {
mSubscriptions.reset();
});
mSubscriptions->show();
return 0;
}
......
......@@ -159,7 +159,7 @@ private:
friend class ImapIdleManager;
QList<ResourceTask *> m_taskList; //used to be able to kill tasks
QPointer<SubscriptionDialog> mSubscriptions;
QScopedPointer<SubscriptionDialog, QScopedPointerDeleteLater> mSubscriptions;
ImapIdleManager *m_idle = nullptr;
QTimer *m_statusMessageTimer = nullptr;
QChar m_separatorCharacter;
......
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