From b9593a06bc287b778b4cdc7bea8bb7705018eaa8 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Tue, 2 Feb 2021 17:39:04 +0100 Subject: [PATCH] [Notifications] When application responds to cancel request, stop kill timer This ensures that an error message the app might have sent in response to the cancel request is still shown. Also, while at it deduplicate code by calling into `terminate` from the service watcher. --- libnotificationmanager/job_p.cpp | 4 ++++ libnotificationmanager/jobsmodel_p.cpp | 13 ++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/libnotificationmanager/job_p.cpp b/libnotificationmanager/job_p.cpp index 22adc1d60..dcef521e4 100644 --- a/libnotificationmanager/job_p.cpp +++ b/libnotificationmanager/job_p.cpp @@ -265,6 +265,10 @@ void JobPrivate::finish() return; } + if (m_killTimer) { + m_killTimer->stop(); + } + Job *job = static_cast(parent()); // update timestamp job->resetUpdated(); diff --git a/libnotificationmanager/jobsmodel_p.cpp b/libnotificationmanager/jobsmodel_p.cpp index c1a4c6dc0..d3fed155e 100644 --- a/libnotificationmanager/jobsmodel_p.cpp +++ b/libnotificationmanager/jobsmodel_p.cpp @@ -482,15 +482,10 @@ void JobsModelPrivate::onServiceUnregistered(const QString &serviceName) if (job->state() == Notifications::JobStateStopped) { continue; } - job->setError(KIO::ERR_OWNER_DIED); - job->setErrorText(i18n("Application closed unexpectedly.")); - job->setState(Notifications::JobStateStopped); - - // basically JobPrivate::finish() - // update timestamp - job->resetUpdated(); - // when it was hidden in history, bring it up again - job->setDismissed(false); + + job->d->terminate(KIO::ERR_OWNER_DIED, + i18n("Application closed unexpectedly."), + {} /*hints*/); } Q_ASSERT(!m_serviceWatcher->watchedServices().contains(serviceName));