diff --git a/server/abstractport.cpp b/server/abstractport.cpp index 56a9530..2fb0b0d 100644 --- a/server/abstractport.cpp +++ b/server/abstractport.cpp @@ -200,11 +200,13 @@ void AbstractPort::addNote(QString note) bool AbstractPort::setTrackStreamStats(bool enable) { - if (enable) - streamTiming_->start(id()); - else - streamTiming_->stop(id()); - + // XXX: This function is called by modify() in context of the RPC + // thread (1 thread per connected client), but the StreamTiming + // singleton resides in the main thread and its' start/stop methods + // start/stop timers which cannot be done across Qt Threads. Hence + // this slightly hacky way of invoking those methods + QMetaObject::invokeMethod(streamTiming_, enable ? "start" : "stop", + Qt::QueuedConnection, Q_ARG(uint, id())); data_.set_is_tracking_stream_stats(enable); return true; diff --git a/server/streamtiming.h b/server/streamtiming.h index d54f690..bd9fb78 100644 --- a/server/streamtiming.h +++ b/server/streamtiming.h @@ -33,10 +33,6 @@ class StreamTiming : public QObject { Q_OBJECT public: - - void start(uint portId); - void stop(uint portId); - bool recordTxTime(uint portId, uint guid, uint ttagId, const struct timespec ×tamp); bool recordRxTime(uint portId, uint guid, uint ttagId, @@ -52,6 +48,10 @@ public: static StreamTiming* instance(); +public slots: + void start(uint portId); + void stop(uint portId); + private: StreamTiming(QObject *parent=nullptr);