Avoid string-based, dynamic lookup of signals
Qt5 has a new function QMetaMethod::fromSignal() for obtaining the meta-method that corresponds to a particular signal (member function). This also avoids calling the virtual metaObject() function to resolve the meta-method every time the signal is emitted; it is known at compile-time which class the signals are defined in, so it's safe to retain the meta-methods across calls. Change-Id: I47328ec2dfc335c570fb18bcd304a2ee405bfd6e Reviewed-by: Dmytro Poplavskiy <dmytro.poplavskiy@nokia.com>
This commit is contained in:
@@ -774,16 +774,16 @@ bool CameraBinSession::processSyncMessage(const QGstreamerMessage &message)
|
||||
}
|
||||
gst_caps_unref(caps);
|
||||
|
||||
static int exposedSignalIndex = metaObject()->indexOfSignal("imageExposed(int)");
|
||||
metaObject()->method(exposedSignalIndex).invoke(this,
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(int,m_requestId));
|
||||
static QMetaMethod exposedSignal = QMetaMethod::fromSignal(&CameraBinSession::imageExposed);
|
||||
exposedSignal.invoke(this,
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(int,m_requestId));
|
||||
|
||||
static int signalIndex = metaObject()->indexOfSignal("imageCaptured(int,QImage)");
|
||||
metaObject()->method(signalIndex).invoke(this,
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(int,m_requestId),
|
||||
Q_ARG(QImage,img));
|
||||
static QMetaMethod capturedSignal = QMetaMethod::fromSignal(&CameraBinSession::imageCaptured);
|
||||
capturedSignal.invoke(this,
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(int,m_requestId),
|
||||
Q_ARG(QImage,img));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user