Make app QObject parent of StreamTiming singleton

This commit is contained in:
Srivats P 2023-04-27 11:09:31 +05:30
parent b9345463c4
commit e761bfa5c4
2 changed files with 5 additions and 4 deletions

View File

@ -23,8 +23,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include <QCoreApplication> #include <QCoreApplication>
StreamTiming::StreamTiming() StreamTiming::StreamTiming(QObject *parent)
: QObject(nullptr) // FIXME: parent : QObject(parent)
{ {
// This class must be part of the main thread so that timers can work // This class must be part of the main thread so that timers can work
Q_ASSERT(this->thread() == QCoreApplication::instance()->thread()); Q_ASSERT(this->thread() == QCoreApplication::instance()->thread());
@ -219,7 +219,7 @@ StreamTiming* StreamTiming::instance()
static StreamTiming *instance{nullptr}; static StreamTiming *instance{nullptr};
if (!instance) if (!instance)
instance = new StreamTiming(); instance = new StreamTiming(QCoreApplication::instance());
return instance; return instance;
} }

View File

@ -32,7 +32,6 @@ class StreamTiming : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
StreamTiming();
bool recordTxTime(uint portId, uint guid, uint ttagId, bool recordTxTime(uint portId, uint guid, uint ttagId,
const struct timespec &timestamp); const struct timespec &timestamp);
@ -50,6 +49,8 @@ public:
static StreamTiming* instance(); static StreamTiming* instance();
private: private:
StreamTiming(QObject *parent=nullptr);
int processRecords(); int processRecords();
int deleteStaleRecords(); int deleteStaleRecords();