From 5ac716494ede76e7a8efe63f9d36d4f89c1ea4de Mon Sep 17 00:00:00 2001 From: synacker Date: Sun, 10 Dec 2023 20:07:08 +0300 Subject: [PATCH] Fixed thread termination --- src/Daggy/CConsoleDaggy.cpp | 11 ++++++++--- src/Daggy/CConsoleDaggy.hpp | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Daggy/CConsoleDaggy.cpp b/src/Daggy/CConsoleDaggy.cpp index 9c57069d..f539f381 100644 --- a/src/Daggy/CConsoleDaggy.cpp +++ b/src/Daggy/CConsoleDaggy.cpp @@ -47,10 +47,17 @@ CConsoleDaggy::CConsoleDaggy(QObject* parent) connect(qApp, &QCoreApplication::aboutToQuit, this, &CConsoleDaggy::fixPcaps); } +CConsoleDaggy::~CConsoleDaggy() +{ + file_thread_.terminate(); + file_thread_.wait(); +} + std::error_code CConsoleDaggy::prepare() { if (daggy_core_) return errors::success; + settings_ = parse(); Sources sources; switch (settings_.data_source_text_type) { @@ -88,15 +95,13 @@ std::error_code CConsoleDaggy::start() void CConsoleDaggy::stop() { if (need_hard_stop_) { - qWarning() << "HARD STOP"; + console_aggreagator_->printAppMessage("HARD STOP"); delete daggy_core_; qApp->exit(); } else { daggy_core_->stop(); need_hard_stop_ = true; } - file_thread_.quit(); - file_thread_.wait(); } bool CConsoleDaggy::handleSystemSignal(const int signal) diff --git a/src/Daggy/CConsoleDaggy.hpp b/src/Daggy/CConsoleDaggy.hpp index e7acc4be..e04e4f72 100644 --- a/src/Daggy/CConsoleDaggy.hpp +++ b/src/Daggy/CConsoleDaggy.hpp @@ -49,6 +49,7 @@ class CConsoleDaggy : public QObject, Q_OBJECT public: CConsoleDaggy(QObject* parent = nullptr); + ~CConsoleDaggy(); std::error_code prepare(); std::error_code start();