diff --git a/src/transactionprivate.cpp b/src/transactionprivate.cpp index b4b44b7..5e219a1 100644 --- a/src/transactionprivate.cpp +++ b/src/transactionprivate.cpp @@ -188,14 +188,18 @@ void TransactionPrivate::runQueuedTransaction() return; } - if (reply.isFinished() && reply.isError()) { - q->errorCode(Transaction::ErrorInternalError, reply.error().message()); - finished(Transaction::ExitFailed, 0); + if (reply.isFinished()) { + receivedReply = true; + if (reply.isError()) { + q->errorCode(Transaction::ErrorInternalError, reply.error().message()); + finished(Transaction::ExitFailed, 0); + } return; } auto watcher = new QDBusPendingCallWatcher(reply, q); q->connect(watcher, &QDBusPendingCallWatcher::finished, q, [this, q] (QDBusPendingCallWatcher *call) { + receivedReply = true; QDBusPendingReply<> reply = *call; if (reply.isError()) { QDBusError error = reply.error(); @@ -204,6 +208,8 @@ void TransactionPrivate::runQueuedTransaction() q->errorCode(transactionError, error.message()); finished(Transaction::ExitFailed, 0); destroy(); + } else if (destroyOnReply) { + destroy(); } call->deleteLater(); }); @@ -248,6 +254,12 @@ void TransactionPrivate::finished(uint exitCode, uint runtime) void TransactionPrivate::destroy() { Q_Q(Transaction); + + if (!receivedReply) { + destroyOnReply = true; + return; + } + if (p) { delete p; p = nullptr; diff --git a/src/transactionprivate.h b/src/transactionprivate.h index 69217a8..bbdf87d 100644 --- a/src/transactionprivate.h +++ b/src/transactionprivate.h @@ -82,6 +82,8 @@ class TransactionPrivate uint uid = 0; QString senderName; bool sentFinished = false; + bool receivedReply = false; + bool destroyOnReply = false; bool allowCancel = false; bool callerActive = false;