From b1e1c704b1849e7ac875a0a310987e81349326c8 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Tue, 16 Feb 2021 18:50:43 +0100 Subject: [PATCH] Use QTimer::singleShot() to delay signal from MessageReply --- ext/libstrawberry-common/core/messagereply.cpp | 2 +- ext/libstrawberry-common/core/messagereply.h | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/ext/libstrawberry-common/core/messagereply.cpp b/ext/libstrawberry-common/core/messagereply.cpp index 98bf1a3d0..3a54e9db8 100644 --- a/ext/libstrawberry-common/core/messagereply.cpp +++ b/ext/libstrawberry-common/core/messagereply.cpp @@ -40,7 +40,7 @@ void _MessageReplyBase::Abort() { finished_ = true; success_ = false; - emit Finished(success_); + emit Finished(); qLog(Debug) << "Releasing ID" << id() << "(aborted)"; semaphore_.release(); diff --git a/ext/libstrawberry-common/core/messagereply.h b/ext/libstrawberry-common/core/messagereply.h index a0f1336ee..2b0fec900 100644 --- a/ext/libstrawberry-common/core/messagereply.h +++ b/ext/libstrawberry-common/core/messagereply.h @@ -20,9 +20,9 @@ #include #include -#include #include #include +#include #include "core/logging.h" @@ -45,7 +45,7 @@ class _MessageReplyBase : public QObject { void Abort(); signals: - void Finished(bool success); + void Finished(); protected: bool finished_; @@ -89,10 +89,8 @@ void MessageReply::SetReply(const MessageType &message) { qLog(Debug) << "Releasing ID" << id() << "(finished)"; semaphore_.release(); - // The signal is not always emitted without this. - QThread::usleep(10); - - emit Finished(success_); + // Delay the signal as workaround to fix the signal periodically not emitted. + QTimer::singleShot(1, this, &_MessageReplyBase::Finished); }