summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dependencies.yaml4
-rw-r--r--src/remoteobjects/qremoteobjectabstractitemmodeladapter.cpp14
-rw-r--r--src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp14
-rw-r--r--src/remoteobjects/qremoteobjectabstractitemmodeltypes.h26
-rw-r--r--src/remoteobjects/qremoteobjectdynamicreplica.cpp12
-rw-r--r--src/remoteobjects/qremoteobjectnode.cpp191
-rw-r--r--src/remoteobjects/qremoteobjectregistry.cpp2
-rw-r--r--src/remoteobjects/qremoteobjectregistrysource.cpp2
-rw-r--r--src/remoteobjects/qremoteobjectreplica.cpp2
-rw-r--r--src/remoteobjects/qremoteobjectsource.cpp4
-rw-r--r--src/remoteobjects/qremoteobjectsource.h2
-rw-r--r--src/remoteobjects/qremoteobjectsourceio.cpp2
-rw-r--r--tests/auto/integration/tst_integration.cpp4
-rw-r--r--tests/auto/modelreplica/tst_modelreplicatest.cpp2
-rw-r--r--tests/auto/proxy/tst_proxy.cpp2
-rw-r--r--tests/auto/proxy_multiprocess/client/main.cpp2
-rw-r--r--tools/repc/cppcodegenerator.cpp1
-rw-r--r--tools/repc/repcodegenerator.cpp20
-rw-r--r--tools/repc/repcodegenerator.h2
19 files changed, 177 insertions, 131 deletions
diff --git a/dependencies.yaml b/dependencies.yaml
index a061db8..3279251 100644
--- a/dependencies.yaml
+++ b/dependencies.yaml
@@ -1,7 +1,7 @@
dependencies:
../qtbase:
- ref: 51e3cd89a81abdbf2fb6c60054d418084e4474c4
+ ref: 32a2c8b4e43b60e0f0ec51deac2d3c8ff3c4b733
required: true
../qtdeclarative:
- ref: 3debb37250b2c57aaaf81940f9dfeb540fd4e380
+ ref: 165ba01a6833e88896cf3f323d8fad67561e1edd
required: false
diff --git a/src/remoteobjects/qremoteobjectabstractitemmodeladapter.cpp b/src/remoteobjects/qremoteobjectabstractitemmodeladapter.cpp
index a7c9be0..349f1dc 100644
--- a/src/remoteobjects/qremoteobjectabstractitemmodeladapter.cpp
+++ b/src/remoteobjects/qremoteobjectabstractitemmodeladapter.cpp
@@ -92,18 +92,14 @@ void QAbstractItemModelSourceAdapter::registerTypes()
alreadyRegistered = true;
qRegisterMetaType<QAbstractItemModel*>();
qRegisterMetaType<Qt::Orientation>();
- qRegisterMetaType<QVector<Qt::Orientation> >();
- qRegisterMetaTypeStreamOperators<ModelIndex>();
- qRegisterMetaTypeStreamOperators<IndexList>();
- qRegisterMetaTypeStreamOperators<DataEntries>();
- qRegisterMetaTypeStreamOperators<MetaAndDataEntries>();
- qRegisterMetaTypeStreamOperators<Qt::Orientation>();
- qRegisterMetaTypeStreamOperators<QVector<Qt::Orientation> >();
+ qRegisterMetaType<QVector<Qt::Orientation>>();
+ qRegisterMetaType<ModelIndex>();
+ qRegisterMetaType<IndexList>();
+ qRegisterMetaType<DataEntries>();
+ qRegisterMetaType<MetaAndDataEntries>();
qRegisterMetaType<QItemSelectionModel::SelectionFlags>();
- qRegisterMetaTypeStreamOperators<QItemSelectionModel::SelectionFlags>();
qRegisterMetaType<QSize>();
qRegisterMetaType<QIntHash>();
- qRegisterMetaTypeStreamOperators<QIntHash>();
}
QItemSelectionModel* QAbstractItemModelSourceAdapter::selectionModel() const
diff --git a/src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp b/src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp
index c830557..9c306f5 100644
--- a/src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp
+++ b/src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp
@@ -117,18 +117,14 @@ void QAbstractItemModelReplicaImplementation::registerMetatypes()
alreadyRegistered = true;
qRegisterMetaType<QAbstractItemModel*>();
qRegisterMetaType<Qt::Orientation>();
- qRegisterMetaType<QVector<Qt::Orientation> >();
- qRegisterMetaTypeStreamOperators<ModelIndex>();
- qRegisterMetaTypeStreamOperators<IndexList>();
- qRegisterMetaTypeStreamOperators<DataEntries>();
- qRegisterMetaTypeStreamOperators<MetaAndDataEntries>();
- qRegisterMetaTypeStreamOperators<Qt::Orientation>();
- qRegisterMetaTypeStreamOperators<QVector<Qt::Orientation> >();
- qRegisterMetaTypeStreamOperators<QItemSelectionModel::SelectionFlags>();
+ qRegisterMetaType<QVector<Qt::Orientation>>();
+ qRegisterMetaType<ModelIndex>();
+ qRegisterMetaType<IndexList>();
+ qRegisterMetaType<DataEntries>();
+ qRegisterMetaType<MetaAndDataEntries>();
qRegisterMetaType<QItemSelectionModel::SelectionFlags>();
qRegisterMetaType<QSize>();
qRegisterMetaType<QIntHash>();
- qRegisterMetaTypeStreamOperators<QIntHash>();
}
void QAbstractItemModelReplicaImplementation::initializeModelConnections()
diff --git a/src/remoteobjects/qremoteobjectabstractitemmodeltypes.h b/src/remoteobjects/qremoteobjectabstractitemmodeltypes.h
index 9fab3dd..ae6149e 100644
--- a/src/remoteobjects/qremoteobjectabstractitemmodeltypes.h
+++ b/src/remoteobjects/qremoteobjectabstractitemmodeltypes.h
@@ -152,6 +152,19 @@ inline QDebug operator<<(QDebug stream, const IndexValuePair &pair)
return stream.nospace() << "IndexValuePair[index=" << pair.index << ", data=" << pair.data << ", hasChildren=" << pair.hasChildren << ", flags=" << pair.flags << "]";
}
+inline QDataStream& operator<<(QDataStream &stream, const IndexValuePair &pair)
+{
+ return stream << pair.index << pair.data << pair.hasChildren << static_cast<int>(pair.flags) << pair.children << pair.size;
+}
+
+inline QDataStream& operator>>(QDataStream &stream, IndexValuePair &pair)
+{
+ int flags;
+ QDataStream &ret = stream >> pair.index >> pair.data >> pair.hasChildren >> flags >> pair.children >> pair.size;
+ pair.flags = static_cast<Qt::ItemFlags>(flags);
+ return ret;
+}
+
inline QDebug operator<<(QDebug stream, const DataEntries &entries)
{
return stream.nospace() << "DataEntries[" << entries.data << "]";
@@ -177,19 +190,6 @@ inline QDataStream& operator>>(QDataStream &stream, MetaAndDataEntries &entries)
return stream >> entries.data >> entries.roles >> entries.size;
}
-inline QDataStream& operator<<(QDataStream &stream, const IndexValuePair &pair)
-{
- return stream << pair.index << pair.data << pair.hasChildren << static_cast<int>(pair.flags) << pair.children << pair.size;
-}
-
-inline QDataStream& operator>>(QDataStream &stream, IndexValuePair &pair)
-{
- int flags;
- QDataStream &ret = stream >> pair.index >> pair.data >> pair.hasChildren >> flags >> pair.children >> pair.size;
- pair.flags = static_cast<Qt::ItemFlags>(flags);
- return ret;
-}
-
inline QString modelIndexToString(const IndexList &list)
{
QString s;
diff --git a/src/remoteobjects/qremoteobjectdynamicreplica.cpp b/src/remoteobjects/qremoteobjectdynamicreplica.cpp
index a004593..0fcfb10 100644
--- a/src/remoteobjects/qremoteobjectdynamicreplica.cpp
+++ b/src/remoteobjects/qremoteobjectdynamicreplica.cpp
@@ -149,7 +149,7 @@ int QRemoteObjectDynamicReplica::qt_metacall(QMetaObject::Call call, int id, voi
if (mp.userType() == QMetaType::QVariant)
args << *reinterpret_cast<QVariant*>(argv[0]);
else
- args << QVariant(mp.userType(), argv[0]);
+ args << QVariant(mp.metaType(), argv[0]);
QRemoteObjectReplica::send(QMetaObject::WriteProperty, saved_id, args);
} else {
if (mp.userType() == QMetaType::QVariant)
@@ -188,17 +188,17 @@ int QRemoteObjectDynamicReplica::qt_metacall(QMetaObject::Call call, int id, voi
if (impl->m_metaObject->indexOfEnumerator(types[i].constData()) != -1) {
const auto size = QMetaType(type).sizeOf();
switch (size) {
- case 1: args.push_back(QVariant(QMetaType::Char, argv[i + 1])); break;
- case 2: args.push_back(QVariant(QMetaType::Short, argv[i + 1])); break;
- case 4: args.push_back(QVariant(QMetaType::Int, argv[i + 1])); break;
+ case 1: args.push_back(QVariant(QMetaType(QMetaType::Char), argv[i + 1])); break;
+ case 2: args.push_back(QVariant(QMetaType(QMetaType::Short), argv[i + 1])); break;
+ case 4: args.push_back(QVariant(QMetaType(QMetaType::Int), argv[i + 1])); break;
// Qt currently only supports enum values of 4 or less bytes (QMetaEnum value(index) returns int)
// case 8: args.push_back(QVariant(QMetaType::Int, argv[i + 1])); break;
default:
qWarning() << "Invalid enum detected (Dynamic Replica)" << QMetaType::typeName(type) << "with size" << size;
- args.push_back(QVariant(QMetaType::Int, argv[i + 1])); break;
+ args.push_back(QVariant(QMetaType(QMetaType::Int), argv[i + 1])); break;
}
} else
- args.push_back(QVariant(type, argv[i + 1]));
+ args.push_back(QVariant(QMetaType(type), argv[i + 1]));
}
if (debugArgs) {
diff --git a/src/remoteobjects/qremoteobjectnode.cpp b/src/remoteobjects/qremoteobjectnode.cpp
index 2d3d56d..6c2f28d 100644
--- a/src/remoteobjects/qremoteobjectnode.cpp
+++ b/src/remoteobjects/qremoteobjectnode.cpp
@@ -67,6 +67,13 @@ struct ManagedGadgetTypeEntry
QMetaType gadgetMetaType;
QVector<QMetaType> enumMetaTypes;
std::shared_ptr<QMetaObject> metaObject;
+
+ void unregisterMetaTypes()
+ {
+ QMetaType::unregisterMetaType(gadgetMetaType);
+ for (auto enumMetaType : enumMetaTypes)
+ QMetaType::unregisterMetaType(enumMetaType);
+ }
};
static QMutex s_managedTypesMutex;
@@ -86,7 +93,7 @@ static void GadgetsStaticMetacallFunction(QObject *_o, QMetaObject::Call _c, int
GadgetType *_t = reinterpret_cast<GadgetType *>(_o);
if (_id < _t->size()) {
auto & prop = (*_t)[_id];
- prop = QVariant(prop.userType(), _a[0]);
+ prop = QVariant(prop.metaType(), _a[0]);
}
}
}
@@ -138,6 +145,16 @@ static bool GadgetEqualsFn(const QtPrivate::QMetaTypeInterface *, const void *a,
return *reinterpret_cast<const GadgetType*>(a) == *reinterpret_cast<const GadgetType*>(b);
}
+static void GadgetDataStreamOutFn(const QtPrivate::QMetaTypeInterface *, QDataStream &ds, const void *a)
+{
+ GadgetSaveOperator(ds, a);
+}
+
+static void GadgetDataStreamInFn(const QtPrivate::QMetaTypeInterface *, QDataStream &ds, void *a)
+{
+ GadgetLoadOperator(ds, a);
+}
+
// Like the Q_GADGET static methods above, we need constructor/destructor methods
// in order to use dynamically defined enums with QVariant or as signal/slot
// parameters (i.e., the queued connection mechanism, which QtRO leverages).
@@ -195,6 +212,24 @@ static bool EnumLessThanFn(const QtPrivate::QMetaTypeInterface *, const void *a,
return *static_cast<const T*>(a) < *static_cast<const T*>(b);
}
+template<typename T>
+static void EnumDebugStreamFn(const QtPrivate::QMetaTypeInterface *, QDebug &dbg, const void *a)
+{
+ dbg << *static_cast<const T *>(a);
+}
+
+template<typename T>
+static void EnumDataStreamOutFn(const QtPrivate::QMetaTypeInterface *, QDataStream &ds, const void *a)
+{
+ ds << *static_cast<const T *>(a);
+}
+
+template<typename T>
+static void EnumDataStreamInFn(const QtPrivate::QMetaTypeInterface *, QDataStream &ds, void *a)
+{
+ ds >> *static_cast<T *>(a);
+}
+
static QString name(const QMetaObject * const mobj)
{
const int ind = mobj->indexOfClassInfo(QCLASSINFO_REMOTEOBJECT_TYPE);
@@ -708,6 +743,8 @@ QRemoteObjectAbstractPersistedStorePrivate::~QRemoteObjectAbstractPersistedStore
QRemoteObjectMetaObjectManager::~QRemoteObjectMetaObjectManager()
{
for (QMetaObject *mo : dynamicTypes) {
+ for (auto metaType : enumTypes[mo])
+ QMetaType::unregisterMetaType(metaType);
enumTypes.remove(mo);
free(mo); //QMetaObjectBuilder uses malloc, not new
}
@@ -736,7 +773,8 @@ static void trackConnection(int typeId, IoDeviceBase *connection)
s_trackedConnections[typeId].remove(connection);
if (s_trackedConnections[typeId].isEmpty()) {
s_trackedConnections.remove(typeId);
- s_managedTypes.remove(typeId); // Destroys the meta types, unregistering them.
+ s_managedTypes[typeId].unregisterMetaTypes();
+ s_managedTypes.remove(typeId); // Destroys the meta types
}
};
@@ -777,7 +815,14 @@ static const char *strDup(const QByteArray &s)
}
using Gadgets = QHash<QByteArray, GadgetData>;
-using TypeInfo = QtPrivate::QMetaTypeInterface;
+struct TypeInfo : public QtPrivate::QMetaTypeInterface
+{
+ const QMetaObject *metaObject;
+};
+static const QMetaObject *metaObjectFn(const QtPrivate::QMetaTypeInterface *self)
+{
+ return static_cast<const TypeInfo *>(self)->metaObject;
+}
template <class Int>
static TypeInfo *enumMetaType(const QByteArray &name, uint size, const QMetaObject *meta=nullptr)
@@ -786,17 +831,20 @@ static TypeInfo *enumMetaType(const QByteArray &name, uint size, const QMetaObje
| QMetaType::NeedsDestruction;
auto typeInfo = new TypeInfo {
- 0, size, alignof(Int), uint(flags), meta, strDup(name), 0,
- // meta is only passed in for Qt types, which don't need to be unregistered.
- Q_BASIC_ATOMIC_INITIALIZER(meta ? -1 : 0),
- [](TypeInfo *self) { delete [] self->name; delete self; },
- EnumConstructor<Int>,
- EnumCopyConstructor<Int>,
- EnumMoveConstructor<Int>,
- EnumDestructor<Int>,
- EnumEqualsFn<Int>,
- EnumLessThanFn<Int>,
- nullptr };
+ {
+ 0, alignof(Int), size, uint(flags), 0, metaObjectFn, strDup(name),
+ EnumConstructor<Int>,
+ EnumCopyConstructor<Int>,
+ EnumMoveConstructor<Int>,
+ EnumDestructor<Int>,
+ EnumEqualsFn<Int>,
+ EnumLessThanFn<Int>,
+ EnumDebugStreamFn<Int>,
+ EnumDataStreamOutFn<Int>,
+ EnumDataStreamInFn<Int>,
+ nullptr
+ }, meta
+ };
return typeInfo;
}
@@ -847,7 +895,7 @@ static int registerGadgets(IoDeviceBase *connection, Gadgets &gadgets, QByteArra
QMetaObjectBuilder gadgetBuilder;
gadgetBuilder.setClassName(typeName);
- gadgetBuilder.setFlags(QMetaObjectBuilder::DynamicMetaObject | QMetaObjectBuilder::PropertyAccessInStaticMetaCall);
+ gadgetBuilder.setFlags(DynamicMetaObject | PropertyAccessInStaticMetaCall);
for (const auto &prop : gadget.properties) {
int propertyType = QMetaType::type(prop.type);
if (!propertyType && gadgets.contains(prop.type))
@@ -889,31 +937,41 @@ static int registerGadgets(IoDeviceBase *connection, Gadgets &gadgets, QByteArra
meta->d.superdata = nullptr;
flags |= QMetaType::NeedsConstruction | QMetaType::NeedsDestruction;
auto typeInfo = new TypeInfo {
- 0, sizeof(GadgetType), alignof(GadgetType), uint(flags), meta,
- strDup(typeName), 0,
- Q_BASIC_ATOMIC_INITIALIZER(0),
- [](TypeInfo *self) { delete [] self->name; delete self; },
- GadgetTypedConstructor,
- GadgetTypedCopyConstructor,
- GadgetTypedMoveConstructor,
- GadgetTypedDestructor,
- GadgetEqualsFn,
- nullptr,
- nullptr };
+ {
+ 0, alignof(GadgetType), sizeof(GadgetType), uint(flags), 0, metaObjectFn,
+ strDup(typeName),
+ GadgetTypedConstructor,
+ GadgetTypedCopyConstructor,
+ GadgetTypedMoveConstructor,
+ GadgetTypedDestructor,
+ GadgetEqualsFn,
+ nullptr, /* LessThanFn */
+ nullptr, /* DebugStreamFn */
+ GadgetDataStreamOutFn,
+ GadgetDataStreamInFn,
+ nullptr /* LegacyRegisterOp */
+ },
+ meta
+ };
entry.gadgetMetaType = QMetaType(typeInfo);
- QMetaType::registerStreamOperators(entry.gadgetMetaType.id(), &GadgetSaveOperator, &GadgetLoadOperator);
} else {
auto typeInfo = new TypeInfo {
- 0, sizeof(GadgetType), alignof(GadgetType), uint(flags), meta, strDup(typeName), 0,
- Q_BASIC_ATOMIC_INITIALIZER(0),
- [](TypeInfo *self) { delete [] self->name; delete self; },
- nullptr,
- nullptr,
- nullptr,
- nullptr,
- nullptr,
- nullptr,
- nullptr };
+ {
+ 0, alignof(GadgetType), sizeof(GadgetType), uint(flags), 0, metaObjectFn,
+ strDup(typeName),
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr
+ },
+ meta
+ };
entry.gadgetMetaType = QMetaType(typeInfo);
}
const int gadgetTypeId = entry.gadgetMetaType.id();
@@ -985,7 +1043,7 @@ QMetaObject *QRemoteObjectMetaObjectManager::addDynamicType(IoDeviceBase *connec
{
QMetaObjectBuilder builder;
builder.setSuperClass(&QRemoteObjectReplica::staticMetaObject);
- builder.setFlags(QMetaObjectBuilder::DynamicMetaObject);
+ builder.setFlags(DynamicMetaObject);
QString typeString;
QByteArray type;
@@ -1065,9 +1123,17 @@ QMetaObject *QRemoteObjectMetaObjectManager::addDynamicType(IoDeviceBase *connec
in >> name;
in >> typeName;
in >> signalName;
- const auto choppedName = QByteArray::fromRawData(typeName.constData(), typeName.size()-1); // Remove trailing null
- if (classEnums.contains(choppedName))
- typeName = classEnums[choppedName] + '\0'; // Update to the enum's registered name
+
+ auto choppedName = QByteArray::fromRawData(typeName.constData(),
+ typeName.size() - 1); // Remove trailing null
+ // The typeName for class enums is qualified with the class name.
+ // Need to remove the class name before checking if it's a class enum.
+ if (auto idx = choppedName.indexOf("::"); idx >= 0) {
+ choppedName = choppedName.sliced(idx + 2);
+ if (classEnums.contains(choppedName))
+ typeName = classEnums[choppedName] + '\0'; // Update to the enum's registered name
+ }
+
if (signalName.isEmpty())
builder.addProperty(name, typeName);
else
@@ -1076,7 +1142,8 @@ QMetaObject *QRemoteObjectMetaObjectManager::addDynamicType(IoDeviceBase *connec
auto meta = builder.toMetaObject();
for (auto typeInfo : enumsToBeAssignedMetaObject.keys()) {
- typeInfo->metaObject = meta;
+ auto typeInfoWithMetaObject = static_cast<TypeInfo *>(typeInfo);
+ typeInfoWithMetaObject->metaObject = meta;
enumTypes[meta].append(enumsToBeAssignedMetaObject.take(typeInfo));
}
dynamicTypes.insert(typeString, meta);
@@ -1185,6 +1252,17 @@ bool QRemoteObjectNodePrivate::hasInstance(const QString &name)
return true;
}
+static QDebug operator<<(QDebug debug,
+ const QHash<QString, QWeakPointer<QReplicaImplementationInterface>> &hash)
+{
+ const QDebugStateSaver saver(debug);
+ debug.nospace() << "QHash(";
+ for (auto it = hash.cbegin(); it != hash.cend(); ++it)
+ debug << '(' << it.key() << ", " << it.value().isNull() << ')';
+ debug << ')';
+ return debug;
+}
+
void QRemoteObjectNodePrivate::onRemoteObjectSourceAdded(const QRemoteObjectSourceLocation &entry)
{
qROPrivDebug() << "onRemoteObjectSourceAdded" << entry << replicas << replicas.contains(entry.first);
@@ -1352,7 +1430,7 @@ void QRemoteObjectNodePrivate::onClientRead(QObject *obj)
}
switch (packetType) {
- case Pong:
+ case QRemoteObjectPacketTypeEnum::Pong:
{
QSharedPointer<QRemoteObjectReplicaImplementation> rep = qSharedPointerCast<QRemoteObjectReplicaImplementation>(replicas.value(rxName).toStrongRef());
if (rep)
@@ -1361,7 +1439,7 @@ void QRemoteObjectNodePrivate::onClientRead(QObject *obj)
replicas.remove(rxName);
break;
}
- case Handshake:
+ case QRemoteObjectPacketTypeEnum::Handshake:
if (rxName != QtRemoteObjects::protocolVersion) {
qWarning() << "*** Protocol Mismatch, closing connection ***. Got" << rxName << "expected" << QtRemoteObjects::protocolVersion;
setLastError(QRemoteObjectNode::ProtocolMismatch);
@@ -1370,7 +1448,7 @@ void QRemoteObjectNodePrivate::onClientRead(QObject *obj)
m_handshakeReceived = true;
}
break;
- case ObjectList:
+ case QRemoteObjectPacketTypeEnum::ObjectList:
{
deserializeObjectListPacket(connection->stream(), rxObjects);
qROPrivDebug() << "newObjects:" << rxObjects;
@@ -1393,7 +1471,7 @@ void QRemoteObjectNodePrivate::onClientRead(QObject *obj)
}
break;
}
- case InitPacket:
+ case QRemoteObjectPacketTypeEnum::InitPacket:
{
qROPrivDebug() << "InitPacket-->" << rxName << this;
QSharedPointer<QConnectedReplicaImplementation> rep = qSharedPointerCast<QConnectedReplicaImplementation>(replicas.value(rxName).toStrongRef());
@@ -1408,7 +1486,7 @@ void QRemoteObjectNodePrivate::onClientRead(QObject *obj)
}
break;
}
- case InitDynamicPacket:
+ case QRemoteObjectPacketTypeEnum::InitDynamicPacket:
{
qROPrivDebug() << "InitDynamicPacket-->" << rxName << this;
const QMetaObject *meta = dynamicTypeManager.addDynamicType(connection, connection->stream());
@@ -1424,7 +1502,7 @@ void QRemoteObjectNodePrivate::onClientRead(QObject *obj)
}
break;
}
- case RemoveObject:
+ case QRemoteObjectPacketTypeEnum::RemoveObject:
{
qROPrivDebug() << "RemoveObject-->" << rxName << this;
connectedSources.remove(rxName);
@@ -1440,7 +1518,7 @@ void QRemoteObjectNodePrivate::onClientRead(QObject *obj)
}
break;
}
- case PropertyChangePacket:
+ case QRemoteObjectPacketTypeEnum::PropertyChangePacket:
{
int propertyIndex;
deserializePropertyChangePacket(connection->stream(), propertyIndex, rxValue);
@@ -1471,13 +1549,13 @@ void QRemoteObjectNodePrivate::onClientRead(QObject *obj)
}
break;
}
- case InvokePacket:
+ case QRemoteObjectPacketTypeEnum::InvokePacket:
{
int call, index, serialId, propertyIndex;
deserializeInvokePacket(connection->stream(), call, index, rxArgs, serialId, propertyIndex);
QSharedPointer<QRemoteObjectReplicaImplementation> rep = qSharedPointerCast<QRemoteObjectReplicaImplementation>(replicas.value(rxName).toStrongRef());
if (rep) {
- static QVariant null(QMetaType::QObjectStar, (void*)0);
+ static QVariant null(QMetaType(QMetaType::QObjectStar), nullptr);
QVariant paramValue;
// Qt usually supports 9 arguments, so ten should be usually safe
QVarLengthArray<void*, 10> param(rxArgs.size() + 1);
@@ -1506,7 +1584,7 @@ void QRemoteObjectNodePrivate::onClientRead(QObject *obj)
}
break;
}
- case InvokeReplyPacket:
+ case QRemoteObjectPacketTypeEnum::InvokeReplyPacket:
{
int ackedSerialId;
deserializeInvokeReplyPacket(connection->stream(), ackedSerialId, rxValue);
@@ -1519,9 +1597,9 @@ void QRemoteObjectNodePrivate::onClientRead(QObject *obj)
}
break;
}
- case AddObject:
- case Invalid:
- case Ping:
+ case QRemoteObjectPacketTypeEnum::AddObject:
+ case QRemoteObjectPacketTypeEnum::Invalid:
+ case QRemoteObjectPacketTypeEnum::Ping:
qROPrivWarning() << "Unexpected packet received";
}
} while (connection->bytesAvailable()); // have bytes left over, so do another iteration
@@ -1669,8 +1747,7 @@ void QRemoteObjectNodePrivate::initialize()
qRegisterMetaType<QRemoteObjectNode *>();
qRegisterMetaType<QRemoteObjectNode::ErrorCode>();
qRegisterMetaType<QAbstractSocket::SocketError>(); //For queued qnx error()
- qRegisterMetaTypeStreamOperators<QVector<int> >();
- qRegisterMetaTypeStreamOperators<QRemoteObjectPackets::QRO_>();
+ qRegisterMetaType<QRemoteObjectPackets::QRO_>();
// To support dynamic MODELs, we need to make sure the types are registered
QAbstractItemModelSourceAdapter::registerTypes();
}
diff --git a/src/remoteobjects/qremoteobjectregistry.cpp b/src/remoteobjects/qremoteobjectregistry.cpp
index 5d72dcc..6a96fdf 100644
--- a/src/remoteobjects/qremoteobjectregistry.cpp
+++ b/src/remoteobjects/qremoteobjectregistry.cpp
@@ -116,9 +116,7 @@ void QRemoteObjectRegistry::registerMetatypes()
return;
initialized = true;
qRegisterMetaType<QRemoteObjectSourceLocation>();
- qRegisterMetaTypeStreamOperators<QRemoteObjectSourceLocation>();
qRegisterMetaType<QRemoteObjectSourceLocations>();
- qRegisterMetaTypeStreamOperators<QRemoteObjectSourceLocations>();
}
void QRemoteObjectRegistry::initialize()
diff --git a/src/remoteobjects/qremoteobjectregistrysource.cpp b/src/remoteobjects/qremoteobjectregistrysource.cpp
index ddd7026..fc57c37 100644
--- a/src/remoteobjects/qremoteobjectregistrysource.cpp
+++ b/src/remoteobjects/qremoteobjectregistrysource.cpp
@@ -45,8 +45,6 @@ QT_BEGIN_NAMESPACE
QRegistrySource::QRegistrySource(QObject *parent)
: QObject(parent)
{
- qRegisterMetaTypeStreamOperators<QRemoteObjectSourceLocation>();
- qRegisterMetaTypeStreamOperators<QRemoteObjectSourceLocations>();
}
QRegistrySource::~QRegistrySource()
diff --git a/src/remoteobjects/qremoteobjectreplica.cpp b/src/remoteobjects/qremoteobjectreplica.cpp
index 04d9ca5..0d565a1 100644
--- a/src/remoteobjects/qremoteobjectreplica.cpp
+++ b/src/remoteobjects/qremoteobjectreplica.cpp
@@ -863,7 +863,7 @@ QRemoteObjectPendingCall QInProcessReplicaImplementation::_q_sendWithReply(QMeta
int typeId = QMetaType::type(connectionToSource->m_api->typeName(ReplicaIndex).constData());
if (!QMetaType(typeId).sizeOf())
typeId = QVariant::Invalid;
- QVariant returnValue(typeId, nullptr);
+ QVariant returnValue(QMetaType(typeId), nullptr);
const int resolvedIndex = connectionToSource->m_api->sourceMethodIndex(ReplicaIndex);
if (resolvedIndex < 0) {
diff --git a/src/remoteobjects/qremoteobjectsource.cpp b/src/remoteobjects/qremoteobjectsource.cpp
index 6cf059e..869f37a 100644
--- a/src/remoteobjects/qremoteobjectsource.cpp
+++ b/src/remoteobjects/qremoteobjectsource.cpp
@@ -300,14 +300,14 @@ QVariantList* QRemoteObjectSourceBase::marshalArgs(int index, void **a)
if (type == QMetaType::QVariant)
list[i] = *reinterpret_cast<QVariant *>(a[i + 1]);
else
- list[i] = QVariant(type, a[i + 1]);
+ list[i] = QVariant(QMetaType(type), a[i + 1]);
}
for (int i = list.size(); i < N; ++i) {
const int type = m_api->signalParameterType(index, i);
if (type == QMetaType::QVariant)
list << *reinterpret_cast<QVariant *>(a[i + 1]);
else
- list << QVariant(type, a[i + 1]);
+ list << QVariant(QMetaType(type), a[i + 1]);
}
for (int i = N; i < list.size(); ++i)
list.removeLast();
diff --git a/src/remoteobjects/qremoteobjectsource.h b/src/remoteobjects/qremoteobjectsource.h
index 9404a55..097e599 100644
--- a/src/remoteobjects/qremoteobjectsource.h
+++ b/src/remoteobjects/qremoteobjectsource.h
@@ -139,7 +139,7 @@ inline bool apiMethodMatch(const QMetaObject *m, const Data &data,
for (int i = 0; i < argc; ++i) {
uint typeInfo = m->d.data[paramsIndex + i];
if (typeInfo & 0x80000000) { // Custom/named type, compare names
- const char *t = QMetaType::typeName(types[i]);
+ const char *t = QMetaType(types[i]).name();
const auto type = QByteArray::fromRawData(t, qstrlen(t));
if (type != apiStringData(m, typeInfo & 0x7FFFFFFF))
return false;
diff --git a/src/remoteobjects/qremoteobjectsourceio.cpp b/src/remoteobjects/qremoteobjectsourceio.cpp
index a6cdd11..aed3f6d 100644
--- a/src/remoteobjects/qremoteobjectsourceio.cpp
+++ b/src/remoteobjects/qremoteobjectsourceio.cpp
@@ -245,7 +245,7 @@ void QRemoteObjectSourceIo::onServerRead(QObject *conn)
int typeId = QMetaType::type(source->m_api->typeName(index).constData());
if (!QMetaType(typeId).sizeOf())
typeId = QVariant::Invalid;
- QVariant returnValue(typeId, nullptr);
+ QVariant returnValue(QMetaType(typeId), nullptr);
// If a Replica is used as a Source (which node->proxy() does) we can have a PendingCall return value.
// In this case, we need to wait for the pending call and send that.
if (source->m_api->typeName(index) == QByteArrayLiteral("QRemoteObjectPendingCall"))
diff --git a/tests/auto/integration/tst_integration.cpp b/tests/auto/integration/tst_integration.cpp
index 0be22bf..d1ce6ec 100644
--- a/tests/auto/integration/tst_integration.cpp
+++ b/tests/auto/integration/tst_integration.cpp
@@ -372,7 +372,7 @@ private slots:
QMetaProperty property = metaObject->property(propertyIndex);
QVERIFY(property.isValid());
- QCOMPARE(property.typeName(), "ClassEnum");
+ QCOMPARE(property.typeName(), "TestClassReplica::ClassEnum");
// read enum on the dynamic replica
{
@@ -393,7 +393,7 @@ private slots:
property = metaObject->property(propertyIndex);
QVERIFY(property.isValid());
- QCOMPARE(property.typeName(), "ClassEnum");
+ QCOMPARE(property.typeName(), "TestClassReplica::ClassEnum");
// read enum on the dynamic replica
{
diff --git a/tests/auto/modelreplica/tst_modelreplicatest.cpp b/tests/auto/modelreplica/tst_modelreplicatest.cpp
index 6954f9e..1ceb996 100644
--- a/tests/auto/modelreplica/tst_modelreplicatest.cpp
+++ b/tests/auto/modelreplica/tst_modelreplicatest.cpp
@@ -90,7 +90,7 @@ void ModelreplicaTest::basicFunctions()
QCOMPARE(model->rowCount(), replica->tracks()->rowCount());
for (int i = 0; i < replica->tracks()->rowCount(); i++)
{
- QCOMPARE(model->data(model->index(i), Qt::DisplayRole), replica->tracks()->data(replica->tracks()->index(i, 0)));
+ QTRY_COMPARE(model->data(model->index(i), Qt::DisplayRole), replica->tracks()->data(replica->tracks()->index(i, 0)));
}
// ensure the tracks objects are distinct
diff --git a/tests/auto/proxy/tst_proxy.cpp b/tests/auto/proxy/tst_proxy.cpp
index 4ce23cd..7fc8024 100644
--- a/tests/auto/proxy/tst_proxy.cpp
+++ b/tests/auto/proxy/tst_proxy.cpp
@@ -254,7 +254,7 @@ void ProxyTest::testProxy()
QVERIFY(w.wait());
for (int i = 0; i < rep->tracks()->rowCount(); i++)
{
- QCOMPARE(rep->tracks()->data(rep->tracks()->index(i, 0)), model.data(model.index(i), Qt::DisplayRole));
+ QTRY_COMPARE(rep->tracks()->data(rep->tracks()->index(i, 0)), model.data(model.index(i), Qt::DisplayRole));
}
//Change SubClass and make sure change propagates
diff --git a/tests/auto/proxy_multiprocess/client/main.cpp b/tests/auto/proxy_multiprocess/client/main.cpp
index 89fe043..e5eee07 100644
--- a/tests/auto/proxy_multiprocess/client/main.cpp
+++ b/tests/auto/proxy_multiprocess/client/main.cpp
@@ -79,7 +79,7 @@ private Q_SLOTS:
auto enumReply = m_rep->enumSlot(p, ParentClassReplica::bar);
QVERIFY(enumReply.waitForFinished());
QCOMPARE(enumReply.error(), QRemoteObjectPendingCall::NoError);
- QCOMPARE(enumReply.returnValue(), QVariant::fromValue(ParentClassReplica::foobar));
+ QCOMPARE(enumReply.returnValue(), ParentClassReplica::foobar);
qDebug() << "Verified expected initial states, sending start.";
QSignalSpy enumSpy(m_rep.data(), &ParentClassReplica::enum2);
diff --git a/tools/repc/cppcodegenerator.cpp b/tools/repc/cppcodegenerator.cpp
index 236c7f1..c82acbb 100644
--- a/tools/repc/cppcodegenerator.cpp
+++ b/tools/repc/cppcodegenerator.cpp
@@ -26,6 +26,7 @@
**
****************************************************************************/
+#include <qiodevice.h>
#include <qjsonarray.h>
#include <qjsonvalue.h>
diff --git a/tools/repc/repcodegenerator.cpp b/tools/repc/repcodegenerator.cpp
index 0da307e..f27346a 100644
--- a/tools/repc/repcodegenerator.cpp
+++ b/tools/repc/repcodegenerator.cpp
@@ -202,8 +202,7 @@ void RepCodeGenerator::generate(const AST &ast, Mode mode, QString fileName)
for (const PODAttribute &attribute : pod.attributes)
metaTypes << attribute.type;
}
- const QString metaTypeRegistrationCode = generateMetaTypeRegistration(metaTypes)
- + generateMetaTypeRegistrationForEnums(ast.enumUses);
+ const QString metaTypeRegistrationCode = generateMetaTypeRegistration(metaTypes);
for (const ASTClass &astClass : ast.classes) {
QSet<QString> classMetaTypes;
@@ -555,7 +554,6 @@ QString RepCodeGenerator::generateMetaTypeRegistration(const QSet<QString> &meta
{
QString out;
const QString qRegisterMetaType = QStringLiteral(" qRegisterMetaType<");
- const QString qRegisterMetaTypeStreamOperators = QStringLiteral(" qRegisterMetaTypeStreamOperators<");
const QString lineEnding = QStringLiteral(">();\n");
for (const QString &metaType : metaTypes) {
if (isBuiltinType(metaType))
@@ -564,10 +562,6 @@ QString RepCodeGenerator::generateMetaTypeRegistration(const QSet<QString> &meta
out += qRegisterMetaType;
out += metaType;
out += lineEnding;
-
- out += qRegisterMetaTypeStreamOperators;
- out += metaType;
- out += lineEnding;
}
return out;
}
@@ -588,18 +582,6 @@ QString RepCodeGenerator::generateMetaTypeRegistrationForPending(const QSet<QStr
return out;
}
-
-QString RepCodeGenerator::generateMetaTypeRegistrationForEnums(const QVector<QString> &enumUses)
-{
- QString out;
-
- for (const QString &enumName : enumUses) {
- out += QLatin1String(" qRegisterMetaTypeStreamOperators<") + enumName + QLatin1String(">(\"") + enumName + QLatin1String("\");\n");
- }
-
- return out;
-}
-
void RepCodeGenerator::generateStreamOperatorsForEnums(QTextStream &out, const QVector<QString> &enumUses)
{
out << "QT_BEGIN_NAMESPACE" << Qt::endl;
diff --git a/tools/repc/repcodegenerator.h b/tools/repc/repcodegenerator.h
index be3353d..f3f5b4b 100644
--- a/tools/repc/repcodegenerator.h
+++ b/tools/repc/repcodegenerator.h
@@ -41,7 +41,6 @@ struct ASTEnum;
struct ASTProperty;
class QIODevice;
-class QStringList;
class QTextStream;
class RepCodeGenerator
@@ -64,7 +63,6 @@ private:
void generateHeader(Mode mode, QTextStream &out, const AST &ast);
QString generateMetaTypeRegistration(const QSet<QString> &metaTypes);
QString generateMetaTypeRegistrationForPending(const QSet<QString> &metaTypes);
- QString generateMetaTypeRegistrationForEnums(const QVector<QString> &enums);
void generateStreamOperatorsForEnums(QTextStream &out, const QVector<QString> &enums);
void generateSimpleSetter(QTextStream &out, const ASTProperty &property, bool generateOverride = true);