From 63c88c69199491555f2400f3e3bd6e20f1a5259f Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Tue, 28 Jun 2016 16:16:51 +0200 Subject: [PATCH] Replace private slot with private method With the new Qt5 C++11 syntax, private slots are not really necessary. Replacing it with a normal private method reduces the generated code from moc and also syntax issues are raised as compiler errors instead of runtime asserts. --- src/blackcore/vatsim/vatsimmetarreader.cpp | 12 +++++------- src/blackcore/vatsim/vatsimmetarreader.h | 6 +++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/blackcore/vatsim/vatsimmetarreader.cpp b/src/blackcore/vatsim/vatsimmetarreader.cpp index 589e0bf9c..0359c6f00 100644 --- a/src/blackcore/vatsim/vatsimmetarreader.cpp +++ b/src/blackcore/vatsim/vatsimmetarreader.cpp @@ -41,14 +41,12 @@ namespace BlackCore CVatsimMetarReader::CVatsimMetarReader(QObject *owner) : CThreadedReader(owner, "CVatsimMetarReader") { - this->connect(this->m_updateTimer, &QTimer::timeout, this, &CVatsimMetarReader::ps_readMetars); + this->connect(this->m_updateTimer, &QTimer::timeout, this, &CVatsimMetarReader::readMetars); } void CVatsimMetarReader::readInBackgroundThread() { - bool s = QMetaObject::invokeMethod(this, "ps_readMetars"); - Q_ASSERT_X(s, Q_FUNC_INFO, "Cannot invoke"); - Q_UNUSED(s); + QTimer::singleShot(0, this, &CVatsimMetarReader::readMetars); } CMetarList CVatsimMetarReader::getMetars() const @@ -79,7 +77,7 @@ namespace BlackCore return m_settings.get(); } - void CVatsimMetarReader::ps_readMetars() + void CVatsimMetarReader::readMetars() { this->threadAssertCheck(); this->restartTimer(true); // when timer active, restart so we cause no undesired reads @@ -88,10 +86,10 @@ namespace BlackCore const CUrl url(urls.obtainNextWorkingUrl(true)); if (url.isEmpty()) { return; } Q_ASSERT_X(sApp, Q_FUNC_INFO, "No Application"); - sApp->getFromNetwork(url.withAppendedQuery("id=all"), { this, &CVatsimMetarReader::ps_decodeMetars}); + sApp->getFromNetwork(url.withAppendedQuery("id=all"), { this, &CVatsimMetarReader::decodeMetars}); } - void CVatsimMetarReader::ps_decodeMetars(QNetworkReply *nwReplyPtr) + void CVatsimMetarReader::decodeMetars(QNetworkReply *nwReplyPtr) { // wrap pointer, make sure any exit cleans up reply // required to use delete later as object is created in a different thread diff --git a/src/blackcore/vatsim/vatsimmetarreader.h b/src/blackcore/vatsim/vatsimmetarreader.h index 490da3c76..1df9cad63 100644 --- a/src/blackcore/vatsim/vatsimmetarreader.h +++ b/src/blackcore/vatsim/vatsimmetarreader.h @@ -66,13 +66,13 @@ namespace BlackCore virtual BlackCore::Settings::CSettingsReader getSettings() const override; //! @} - private slots: + private: //! Decode METARs //! \threadsafe - void ps_decodeMetars(QNetworkReply *nwReply); + void decodeMetars(QNetworkReply *nwReply); //! Do reading - void ps_readMetars(); + void readMetars(); private: BlackMisc::Weather::CMetarDecoder m_metarDecoder;