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.
This commit is contained in:
Roland Winklmeier
2016-06-28 16:16:51 +02:00
parent a3fbbd7a67
commit 63c88c6919
2 changed files with 8 additions and 10 deletions

View File

@@ -41,14 +41,12 @@ namespace BlackCore
CVatsimMetarReader::CVatsimMetarReader(QObject *owner) : CVatsimMetarReader::CVatsimMetarReader(QObject *owner) :
CThreadedReader(owner, "CVatsimMetarReader") 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() void CVatsimMetarReader::readInBackgroundThread()
{ {
bool s = QMetaObject::invokeMethod(this, "ps_readMetars"); QTimer::singleShot(0, this, &CVatsimMetarReader::readMetars);
Q_ASSERT_X(s, Q_FUNC_INFO, "Cannot invoke");
Q_UNUSED(s);
} }
CMetarList CVatsimMetarReader::getMetars() const CMetarList CVatsimMetarReader::getMetars() const
@@ -79,7 +77,7 @@ namespace BlackCore
return m_settings.get(); return m_settings.get();
} }
void CVatsimMetarReader::ps_readMetars() void CVatsimMetarReader::readMetars()
{ {
this->threadAssertCheck(); this->threadAssertCheck();
this->restartTimer(true); // when timer active, restart so we cause no undesired reads 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)); const CUrl url(urls.obtainNextWorkingUrl(true));
if (url.isEmpty()) { return; } if (url.isEmpty()) { return; }
Q_ASSERT_X(sApp, Q_FUNC_INFO, "No Application"); 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 // wrap pointer, make sure any exit cleans up reply
// required to use delete later as object is created in a different thread // required to use delete later as object is created in a different thread

View File

@@ -66,13 +66,13 @@ namespace BlackCore
virtual BlackCore::Settings::CSettingsReader getSettings() const override; virtual BlackCore::Settings::CSettingsReader getSettings() const override;
//! @} //! @}
private slots: private:
//! Decode METARs //! Decode METARs
//! \threadsafe //! \threadsafe
void ps_decodeMetars(QNetworkReply *nwReply); void decodeMetars(QNetworkReply *nwReply);
//! Do reading //! Do reading
void ps_readMetars(); void readMetars();
private: private:
BlackMisc::Weather::CMetarDecoder m_metarDecoder; BlackMisc::Weather::CMetarDecoder m_metarDecoder;