mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-01-31 09:44:50 +01:00
Use QTimer::singleShot() to delay signal from MessageReply
This commit is contained in:
parent
f908336ec6
commit
b1e1c704b1
@ -40,7 +40,7 @@ void _MessageReplyBase::Abort() {
|
||||
finished_ = true;
|
||||
success_ = false;
|
||||
|
||||
emit Finished(success_);
|
||||
emit Finished();
|
||||
qLog(Debug) << "Releasing ID" << id() << "(aborted)";
|
||||
semaphore_.release();
|
||||
|
||||
|
@ -20,9 +20,9 @@
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
#include <QSemaphore>
|
||||
#include <QString>
|
||||
#include <QTimer>
|
||||
|
||||
#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<MessageType>::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);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user