From 2361cc0473376f0af68f23855a29a822167ab244 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Fri, 15 Nov 2019 18:20:26 +0100 Subject: [PATCH] Wait for the job queue to finish before shutting down --- libnymea-core/logging/logengine.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libnymea-core/logging/logengine.cpp b/libnymea-core/logging/logengine.cpp index f1c99b16..1af97270 100644 --- a/libnymea-core/logging/logengine.cpp +++ b/libnymea-core/logging/logengine.cpp @@ -172,15 +172,21 @@ LogEngine::LogEngine(const QString &driver, const QString &dbName, const QString } } - checkDBSize(); - connect(&m_jobWatcher, SIGNAL(finished()), this, SLOT(handleJobFinished())); + checkDBSize(); } /*! Destructs the \l{LogEngine}. */ LogEngine::~LogEngine() { + // Process the job queue before allowing to shut down + while (!m_jobQueue.isEmpty()) { + qApp->processEvents(); + } + if (!m_jobWatcher.isFinished()) { + m_jobWatcher.waitForFinished(); + } m_db.close(); }