diff options
| author | Kevin Funk <kevin.funk.ford@kdab.com> | 2016-05-03 15:09:57 +0200 |
|---|---|---|
| committer | Kevin Funk <kevin.funk@kdab.com> | 2016-05-03 17:00:07 +0000 |
| commit | a82d7ac8985093950753d7d25c686f90eb3b8534 (patch) | |
| tree | 20bd41a0018530ece19ceb84efc1cf1ad98fde19 /src/remoteobjects/qremoteobjectsource.cpp | |
| parent | 883e45c465fe90dbb175b857ddc609cdc8c111c2 (diff) | |
Reduce code duplication a bit
In preparation of upcoming commit
Change-Id: I7043800c64282511011f1a3f4be6ec8f135d5186
Reviewed-by: Continuous Integration (KDAB) <build@kdab.com>
Reviewed-by: Brett Stottlemyer <bstottle@ford.com>
Diffstat (limited to 'src/remoteobjects/qremoteobjectsource.cpp')
| -rw-r--r-- | src/remoteobjects/qremoteobjectsource.cpp | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/src/remoteobjects/qremoteobjectsource.cpp b/src/remoteobjects/qremoteobjectsource.cpp index 42f4355..242af27 100644 --- a/src/remoteobjects/qremoteobjectsource.cpp +++ b/src/remoteobjects/qremoteobjectsource.cpp @@ -81,16 +81,10 @@ QRemoteObjectSource::QRemoteObjectSource(QObject *obj, const SourceApiMap *api, // //We know no one will inherit from this class, so no need to worry about indices from //derived classes. - if (m_api->isAdapterSignal(idx)) { - if (!QMetaObject::connect(adapter, sourceIndex, this, QRemoteObjectSource::qobjectMethodOffset+idx, Qt::DirectConnection, 0)) { - qCWarning(QT_REMOTEOBJECT) << "QRemoteObjectSourcePrivate: QMetaObject::connect returned false. Unable to connect."; - return; - } - } else { - if (!QMetaObject::connect(obj, sourceIndex, this, QRemoteObjectSource::qobjectMethodOffset+idx, Qt::DirectConnection, 0)) { - qCWarning(QT_REMOTEOBJECT) << "QRemoteObjectSourcePrivate: QMetaObject::connect returned false. Unable to connect."; - return; - } + const auto target = m_api->isAdapterSignal(idx) ? adapter : obj; + if (!QMetaObject::connect(target, sourceIndex, this, QRemoteObjectSource::qobjectMethodOffset+idx, Qt::DirectConnection, 0)) { + qCWarning(QT_REMOTEOBJECT) << "QRemoteObjectSourcePrivate: QMetaObject::connect returned false. Unable to connect."; + return; } qCDebug(QT_REMOTEOBJECT) << "Connection made" << idx << meta->method(sourceIndex).name(); @@ -180,15 +174,10 @@ void QRemoteObjectSource::handleMetaCall(int index, QMetaObject::Call call, void const int propertyIndex = m_api->propertyIndexFromSignal(index); if (propertyIndex >= 0) { const int rawIndex = m_api->propertyRawIndexFromSignal(index); - if (m_api->isAdapterProperty(index)) { - const QMetaProperty mp = m_adapter->metaObject()->property(propertyIndex); - qCDebug(QT_REMOTEOBJECT) << "Sending Invoke Property (adapter)" << rawIndex << propertyIndex << mp.name() << mp.read(m_adapter); - serializePropertyChangePacket(m_packet, m_api->name(), rawIndex, serializedProperty(mp, m_adapter)); - } else { - const QMetaProperty mp = m_object->metaObject()->property(propertyIndex); - qCDebug(QT_REMOTEOBJECT) << "Sending Invoke Property" << rawIndex << propertyIndex << mp.name() << mp.read(m_object); - serializePropertyChangePacket(m_packet, m_api->name(), rawIndex, serializedProperty(mp, m_object)); - } + const auto target = m_api->isAdapterProperty(index) ? m_adapter : m_object; + const QMetaProperty mp = target->metaObject()->property(propertyIndex); + qCDebug(QT_REMOTEOBJECT) << "Sending Invoke Property" << (m_api->isAdapterSignal(index) ? "via adapter" : "") << rawIndex << propertyIndex << mp.name() << mp.read(target); + serializePropertyChangePacket(m_packet, m_api->name(), rawIndex, serializedProperty(mp, target)); m_packet.baseAddress = m_packet.size; } |
