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:
+7
-2
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user