Skip to content

Commit

Permalink
Merge pull request #64 from synacker/bug/fix_thread_termination
Browse files Browse the repository at this point in the history
Fixed thread termination
  • Loading branch information
synacker authored Dec 10, 2023
2 parents 10af81c + 5ac7164 commit 434ed8e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Daggy/CConsoleDaggy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/Daggy/CConsoleDaggy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class CConsoleDaggy : public QObject,
Q_OBJECT
public:
CConsoleDaggy(QObject* parent = nullptr);
~CConsoleDaggy();

std::error_code prepare();
std::error_code start();
Expand Down

0 comments on commit 434ed8e

Please sign in to comment.