[pim/kmail] src/undosend: Make sure that we don't delete job before sending
Laurent Montel <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 6398bca97b38b4822ef2661b973e50144f963606 by Laurent Montel.
Committed on 13/08/2026 at 20:16.
Pushed by mlaurent into branch 'master'.
Make sure that we don't delete job before sending
M +10 -1 src/undosend/undosendcreatejob.cpp
https://invent.kde.org/pim/kmail/-/commit/6398bca97b38b4822ef2661b973e50144f963606
diff --git a/src/undosend/undosendcreatejob.cpp b/src/undosend/undosendcreatejob.cpp
index e53a9c39b..e5ea82432 100644
--- a/src/undosend/undosendcreatejob.cpp
+++ b/src/undosend/undosendcreatejob.cpp
@@ -70,8 +70,17 @@ void UndoSendCreateJob::slotNotificationClosed()
void UndoSendCreateJob::undoSendEmail()
{
mTimer->stop();
- auto job = new MessageComposer::SendLaterRemoveJob(mAkonadiIndex, this);
+ // Don't parent the job to "this": closing the notification deletes us, and the job
+ // would be destroyed before its asynchronous dbus call to the send later agent completes.
+ auto job = new MessageComposer::SendLaterRemoveJob(mAkonadiIndex, nullptr);
+ connect(job, &KJob::result, this, [](KJob *job) {
+ if (job->error()) {
+ qCWarning(KMAIL_UNDO_SEND_LOG) << "Impossible to undo send email:" << job->errorString();
+ }
+ });
job->start();
+ // Make sure that we are cleaned up even if the notification backend doesn't close it for us.
+ mNotification->close();
}
QString UndoSendCreateJob::subject() const