summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brasser <mbrasser@ford.com>2017-04-11 12:07:44 -0500
committerMichael Brasser <michael.brasser@live.com>2017-04-12 12:34:03 +0000
commit6937b9326583f4f4b0812ea93f420a9fd2132b85 (patch)
tree0b267a68da13f4284c3c9fbd8164a5d841396ba9
parent0eaa90b1245ba2932c895118418ff9dc4d8ab3c0 (diff)
Don't hide QObject::setProperty for dynamic replicasv5.9.0-beta2
Change-Id: Ibcd573a610cbc88a9b82c45aa3eb6b1e2272744a Reviewed-by: Brett Stottlemyer <bstottle@ford.com>
-rw-r--r--src/remoteobjects/qremoteobjectnode.cpp4
-rw-r--r--src/remoteobjects/qremoteobjectreplica.cpp8
-rw-r--r--src/remoteobjects/qremoteobjectreplica.h1
-rw-r--r--tests/auto/integration/tst_integration.cpp60
4 files changed, 62 insertions, 11 deletions
diff --git a/src/remoteobjects/qremoteobjectnode.cpp b/src/remoteobjects/qremoteobjectnode.cpp
index 9e3e458..acd86a0 100644
--- a/src/remoteobjects/qremoteobjectnode.cpp
+++ b/src/remoteobjects/qremoteobjectnode.cpp
@@ -329,7 +329,7 @@ void QRemoteObjectNodePrivate::onRemoteObjectSourceAdded(const QRemoteObjectSour
QRemoteObjectSourceLocations locs = registry->sourceLocations();
locs[entry.first] = entry.second;
//TODO Is there a way to extend QRemoteObjectSourceLocations in place?
- registry->setProperty(0, QVariant::fromValue(locs));
+ registry->d_ptr->setProperty(0, QVariant::fromValue(locs));
qROPrivDebug() << "onRemoteObjectSourceAdded, now locations =" << locs;
}
if (replicas.contains(entry.first)) //We have a replica waiting on this remoteObject
@@ -351,7 +351,7 @@ void QRemoteObjectNodePrivate::onRemoteObjectSourceRemoved(const QRemoteObjectSo
if (!entry.first.isEmpty()) {
QRemoteObjectSourceLocations locs = registry->sourceLocations();
locs.remove(entry.first);
- registry->setProperty(0, QVariant::fromValue(locs));
+ registry->d_ptr->setProperty(0, QVariant::fromValue(locs));
}
}
diff --git a/src/remoteobjects/qremoteobjectreplica.cpp b/src/remoteobjects/qremoteobjectreplica.cpp
index 05eb71c..91af191 100644
--- a/src/remoteobjects/qremoteobjectreplica.cpp
+++ b/src/remoteobjects/qremoteobjectreplica.cpp
@@ -577,14 +577,6 @@ void QRemoteObjectReplica::setProperties(const QVariantList &properties)
}
/*!
- \internal
-*/
-void QRemoteObjectReplica::setProperty(int i, const QVariant &prop)
-{
- d_ptr->setProperty(i, prop);
-}
-
-/*!
Returns \c true if this replica has been initialized with data from the \l {Source} object. Returns \c false otherwise.
\sa state()
diff --git a/src/remoteobjects/qremoteobjectreplica.h b/src/remoteobjects/qremoteobjectreplica.h
index 347bdb5..f620e1c 100644
--- a/src/remoteobjects/qremoteobjectreplica.h
+++ b/src/remoteobjects/qremoteobjectreplica.h
@@ -83,7 +83,6 @@ protected:
QRemoteObjectPendingCall sendWithReply(QMetaObject::Call call, int index, const QVariantList &args);
protected:
- void setProperty(int i, const QVariant &);
void setProperties(const QVariantList &);
const QVariant propAsVariant(int i) const;
void persistProperties(const QString &repName, const QByteArray &repSig, const QVariantList &props) const;
diff --git a/tests/auto/integration/tst_integration.cpp b/tests/auto/integration/tst_integration.cpp
index 9c35ace..a13bf2a 100644
--- a/tests/auto/integration/tst_integration.cpp
+++ b/tests/auto/integration/tst_integration.cpp
@@ -71,6 +71,32 @@ Q_SIGNALS:
void send(const QByteArray &data);
};
+class TestDynamic : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
+public:
+ TestDynamic(QObject *parent=nullptr) :
+ QObject(parent),
+ m_value(0) {}
+
+ int value() const { return m_value; }
+ void setValue(int value)
+ {
+ if (m_value == value)
+ return;
+
+ m_value = value;
+ emit valueChanged();
+ }
+
+signals:
+ void valueChanged();
+
+private:
+ int m_value;
+};
+
class Persist : public QRemoteObjectPersistedStore
{
public:
@@ -973,6 +999,40 @@ private slots:
QCOMPARE(speedometer_r->mph(), s.mph());
}
+ void rawDynamicReplicaTest()
+ {
+ QRemoteObjectHost host(hostUrl);
+ SET_NODE_NAME(host);
+ TestDynamic source;
+ host.enableRemoting(&source, "TestDynamic");
+
+ QRemoteObjectNode client;
+ client.connectToNode(hostUrl);
+ Q_SET_OBJECT_NAME(client);
+
+ const QScopedPointer<QRemoteObjectDynamicReplica> replica(client.acquireDynamic(QStringLiteral("TestDynamic")));
+ replica->waitForSource();
+ QVERIFY(replica->isInitialized());
+
+ QSignalSpy spy(replica.data(), SIGNAL(valueChanged()));
+
+ const QMetaObject *metaObject = replica->metaObject();
+ const int propIndex = metaObject->indexOfProperty("value");
+ QVERIFY(propIndex != -1);
+ const int signalIndex = metaObject->indexOfSignal("valueChanged()");
+ QVERIFY(signalIndex != -1);
+
+ // replica gets source change
+ source.setValue(1);
+ QTRY_COMPARE(spy.count(), 1);
+ QCOMPARE(replica->property("value"), QVariant(1));
+
+ // source gets replica change
+ replica->setProperty("value", 2);
+ QTRY_COMPARE(replica->property("value"), QVariant(2));
+ QCOMPARE(source.value(), 2);
+ }
+
void dynamicReplicaTest()
{
QRemoteObjectHost host(hostUrl);