Fixing the clock signal to use GLib::Dispatcher to emit the signal so the main thread updates the clockLabel widget

This commit is contained in:
Bernardo Magri
2025-03-11 17:14:32 +00:00
parent b6a6e16d3a
commit 4ff86eb027
4 changed files with 36 additions and 19 deletions
+7 -2
View File
@@ -12,6 +12,10 @@ MineField::MineField(int cols, int rows, int mines): m_rows(rows),
}
}
MineField::~MineField() {
// stopTimer();
}
void MineField::timerTick() {
auto start = std::chrono::system_clock::now();
@@ -35,7 +39,9 @@ void MineField::startTimer() {
void MineField::stopTimer() {
m_timerRunning = false;
m_timerThread.join();
if(m_timerThread.joinable()) {
m_timerThread.join();
}
}
void MineField::initBombs(int x, int y) {
@@ -63,7 +69,6 @@ void MineField::initBombs(int x, int y) {
bool MineField::openCell(int x, int y) {
if(isBomb(x, y)) {
m_exploded = true;
timerThread.join();
gameOverSignal.emit();
stopTimer();
return false;