summaryrefslogtreecommitdiffstats
path: root/src/remoteobjects/qremoteobjectsource.cpp
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-02-01 11:50:31 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-02-01 11:50:31 +0100
commit3df5d656896904d5db5983a7218643f1a43acdbb (patch)
tree3f98942663abaec3a389f5ab15ce67f2c8c9999b /src/remoteobjects/qremoteobjectsource.cpp
parentd3cde521533787f5f91364ffdba3e0a386d131f6 (diff)
parente1c0dbeadcfd34699f080edc49815761672616c1 (diff)
Merge remote-tracking branch 'origin/5.12.1' into 5.12
Diffstat (limited to 'src/remoteobjects/qremoteobjectsource.cpp')
-rw-r--r--src/remoteobjects/qremoteobjectsource.cpp53
1 files changed, 38 insertions, 15 deletions
diff --git a/src/remoteobjects/qremoteobjectsource.cpp b/src/remoteobjects/qremoteobjectsource.cpp
index cae5f31..d855220 100644
--- a/src/remoteobjects/qremoteobjectsource.cpp
+++ b/src/remoteobjects/qremoteobjectsource.cpp
@@ -273,41 +273,64 @@ QVariantList* QRemoteObjectSourceBase::marshalArgs(int index, void **a)
return &m_marshalledArgs;
}
-bool QRemoteObjectSourceBase::invoke(QMetaObject::Call c, bool forAdapter, int index, const QVariantList &args, QVariant* returnValue)
+bool QRemoteObjectSourceBase::invoke(QMetaObject::Call c, int index, const QVariantList &args, QVariant* returnValue)
{
int status = -1;
int flags = 0;
-
+ bool forAdapter = (c == QMetaObject::InvokeMetaMethod ? m_api->isAdapterMethod(index) : m_api->isAdapterProperty(index));
+ int resolvedIndex = (c == QMetaObject::InvokeMetaMethod ? m_api->sourceMethodIndex(index) : m_api->sourcePropertyIndex(index));
+ if (resolvedIndex < 0)
+ return false;
QVarLengthArray<void*, 10> param(args.size() + 1);
if (c == QMetaObject::InvokeMetaMethod) {
+ QMetaMethod method;
+ if (!forAdapter)
+ method = parent()->metaObject()->method(resolvedIndex);
+
if (returnValue) {
- param[0] = returnValue->data();
+ if (!forAdapter && method.isValid() && method.returnType() == QMetaType::QVariant)
+ param[0] = const_cast<void*>(reinterpret_cast<const void*>(returnValue));
+ else
+ param[0] = returnValue->data();
} else {
param[0] = nullptr;
}
+ auto argument = [&](int i) -> void * {
+ if ((forAdapter && m_api->methodParameterType(index, i) == QMetaType::QVariant) ||
+ (method.isValid() && method.parameterType(i) == QMetaType::QVariant)) {
+ return const_cast<void*>(reinterpret_cast<const void*>(&args.at(i)));
+ }
+ return const_cast<void*>(args.at(i).data());
+ };
+
for (int i = 0; i < args.size(); ++i) {
- param[i + 1] = const_cast<void*>(args.at(i).data());
+ param[i + 1] = argument(i);
}
- } else if (c == QMetaObject::WriteProperty) {
+ } else if (c == QMetaObject::WriteProperty || c == QMetaObject::ReadProperty) {
+ bool isQVariant = !forAdapter && parent()->metaObject()->property(resolvedIndex).userType() == QMetaType::QVariant;
for (int i = 0; i < args.size(); ++i) {
- param[i] = const_cast<void*>(args.at(i).data());
+ if (isQVariant)
+ param[i] = const_cast<void*>(reinterpret_cast<const void*>(&args.at(i)));
+ else
+ param[i] = const_cast<void*>(args.at(i).data());
}
- Q_ASSERT(param.size() == 2); // for return-value and setter value
- // check QMetaProperty::write for an explanation of these
- param.append(&status);
- param.append(&flags);
- } else {
- for (int i = 0; i < args.size(); ++i) {
- param[i] = const_cast<void*>(args.at(i).data());
+ if (c == QMetaObject::WriteProperty) {
+ Q_ASSERT(param.size() == 2); // for return-value and setter value
+ // check QMetaProperty::write for an explanation of these
+ param.append(&status);
+ param.append(&flags);
}
+ } else {
+ // Better safe than sorry
+ return false;
}
int r = -1;
if (forAdapter)
- r = m_adapter->qt_metacall(c, index, param.data());
+ r = m_adapter->qt_metacall(c, resolvedIndex, param.data());
else
- r = parent()->qt_metacall(c, index, param.data());
+ r = parent()->qt_metacall(c, resolvedIndex, param.data());
return r == -1 && status == -1;
}