From a8783b0b5be21f10353fe648464faaadd890819c Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 28 Apr 2014 19:28:18 +0200 Subject: [PATCH] Fixes in GUI: start/stop timers --- samples/blackgui/mainwindow.cpp | 15 +++------------ samples/blackgui/mainwindow.h | 7 ++++++- samples/blackgui/mainwindow_init.cpp | 17 +++++++++++++++-- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/samples/blackgui/mainwindow.cpp b/samples/blackgui/mainwindow.cpp index 1d2ea6cb5..9515b82ad 100644 --- a/samples/blackgui/mainwindow.cpp +++ b/samples/blackgui/mainwindow.cpp @@ -73,17 +73,7 @@ void MainWindow::gracefulShutdown() } // shut down all timers - this->stopUpdateTimers(true); - if (this->m_timerContextWatchdog) - { - this->m_timerContextWatchdog->stop(); - this->m_timerContextWatchdog->disconnect(this); - } - if (this->m_timerCollectedCockpitUpdates) - { - this->m_timerCollectedCockpitUpdates->stop(); - this->m_timerCollectedCockpitUpdates->disconnect(this); - } + this->stopAllTimers(true); // if we have a context, we shut some things down if (this->m_contextNetworkAvailable) @@ -253,6 +243,7 @@ bool MainWindow::isContextAudioAvailableCheck() */ void MainWindow::displayStatusMessage(const CStatusMessage &statusMessage) { + if (!this->m_init) return; this->ui->sb_MainStatusBar->show(); this->m_timerStatusBar->start(3000); this->m_statusBarIcon->setPixmap(statusMessage.toIcon()); @@ -271,7 +262,7 @@ void MainWindow::displayStatusMessage(const CStatusMessage &statusMessage) */ void MainWindow::displayStatusMessages(const CStatusMessageList &messages) { - if (messages.isEmpty()) return; + if (!this->m_init || messages.isEmpty()) return; foreach(CStatusMessage msg, messages) { this->displayStatusMessage(msg); diff --git a/samples/blackgui/mainwindow.h b/samples/blackgui/mainwindow.h index fedb7f6dd..a2c87d6b9 100644 --- a/samples/blackgui/mainwindow.h +++ b/samples/blackgui/mainwindow.h @@ -232,6 +232,12 @@ private: */ void stopUpdateTimers(bool disconnect = false); + /*! + * \brief Stop all timers + * \param disconnect also disconnect signal/slots + */ + void stopAllTimers(bool disconnect); + //! Currently selected SELCAL code QString getSelcalCode() const; @@ -244,7 +250,6 @@ private: //! Update simulator page with latest user aircraft data void updateSimulatorData(); - private slots: // diff --git a/samples/blackgui/mainwindow_init.cpp b/samples/blackgui/mainwindow_init.cpp index 3707ba59a..0daaa1387 100644 --- a/samples/blackgui/mainwindow_init.cpp +++ b/samples/blackgui/mainwindow_init.cpp @@ -15,6 +15,7 @@ #include "blackgui/atcstationlistmodel.h" #include "blackgui/keyboardkeylistmodel.h" #include "blackmisc/avselcal.h" +#include "blackmisc/project.h" #include #include #include @@ -325,12 +326,24 @@ void MainWindow::stopUpdateTimers(bool disconnect) this->m_timerUpdateAircraftsInRange->stop(); this->m_timerUpdateAtcStationsOnline->stop(); this->m_timerUpdateUsers->stop(); - this->m_timerAudioTests->stop(); - this->m_timerSimulator->stop(); if (!disconnect) return; this->disconnect(this->m_timerUpdateAircraftsInRange); this->disconnect(this->m_timerUpdateAtcStationsOnline); this->disconnect(this->m_timerUpdateUsers); +} + +void MainWindow::stopAllTimers(bool disconnect) +{ + this->m_timerStatusBar->stop(); + this->m_timerContextWatchdog->stop(); + this->m_timerCollectedCockpitUpdates->stop(); + this->m_timerAudioTests->stop(); + this->m_timerSimulator->stop(); + this->stopUpdateTimers(disconnect); + if (!disconnect) return; + this->disconnect(this->m_timerStatusBar); + this->disconnect(this->m_timerContextWatchdog); + this->disconnect(this->m_timerCollectedCockpitUpdates); this->disconnect(this->m_timerAudioTests); this->disconnect(this->m_timerSimulator); }