Ref T486 Using QMetaObject::invokeMethod with pointer-to-member-function (or functor).

This commit is contained in:
Mat Sutcliffe
2018-12-25 14:27:20 +00:00
parent f48a411f43
commit bd9948bbff
7 changed files with 15 additions and 13 deletions

View File

@@ -129,7 +129,7 @@ namespace BlackCore
ISimulatorListener *listener = m_plugins->getListener(simulatorInfo.getIdentifier());
Q_ASSERT(listener);
QMetaObject::invokeMethod(listener, "stop", Qt::QueuedConnection);
QMetaObject::invokeMethod(listener, &ISimulatorListener::stop, Qt::QueuedConnection);
}
int CContextSimulator::checkListeners()
@@ -480,7 +480,7 @@ namespace BlackCore
// start if not already running
if (!listener->isRunning())
{
const bool s = QMetaObject::invokeMethod(listener, "start", Qt::QueuedConnection);
const bool s = QMetaObject::invokeMethod(listener, &ISimulatorListener::start, Qt::QueuedConnection);
Q_ASSERT_X(s, Q_FUNC_INFO, "cannot invoke method");
Q_UNUSED(s);
}
@@ -993,7 +993,7 @@ namespace BlackCore
ISimulatorListener *listener = m_plugins->getListener(info.getIdentifier());
if (listener)
{
const bool s = QMetaObject::invokeMethod(listener, "stop");
const bool s = QMetaObject::invokeMethod(listener, &ISimulatorListener::stop);
Q_ASSERT_X(s, Q_FUNC_INFO, "Cannot invoke stop");
Q_UNUSED(s);
}

View File

@@ -220,6 +220,7 @@ namespace BlackCore
if (entities == CEntityFlags::NoEntity) { return; }
if (!this->isInternetAccessible(QStringLiteral("No network/internet access, will not read %1").arg(CEntityFlags::flagToString(entities)))) { return; }
//! \todo MS 2018-12 Error: CDatabaseReader has no ps_read method
const bool s = QMetaObject::invokeMethod(this, "ps_read",
Q_ARG(BlackMisc::Network::CEntityFlags::Entity, entities),
Q_ARG(BlackMisc::Db::CDbFlags::DataRetrievalModeFlag, mode),

View File

@@ -47,7 +47,7 @@ namespace BlackCore
void CVatsimStatusFileReader::readInBackgroundThread()
{
const bool s = QMetaObject::invokeMethod(this, "ps_read");
const bool s = QMetaObject::invokeMethod(this, &CVatsimStatusFileReader::ps_read);
Q_ASSERT_X(s, Q_FUNC_INFO, "Invoke failed");
Q_UNUSED(s);
}