From 8cdaeb26552313e7b9d67fa062a3d9ff597c2e06 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Mon, 13 Jul 2020 15:20:46 +0200 Subject: moc: allow wrapper generation for QProperty in pimpl class Previously, only QNotifiedProperty was supported. As moc cannot determine by itself whether the backing property is a QProperty or a QNotifiedProperty, allow NOTIFY false to indicate that it is a plain QProperty. For symmetry, NOTIFY true is also allowed and means that the backing property is a QNotifiedProperty. Change-Id: I66f3105c976ef084198ce8658bc07499a3cb1cd8 Reviewed-by: Ulf Hermann --- tests/auto/tools/moc/tst_moc.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/auto/tools') diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 4ea376df68..1432018647 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -4170,11 +4170,13 @@ class ClassWithPrivateQPropertyShim :public QObject Q_OBJECT public: Q_PRIVATE_QPROPERTY(d_func(), int, testProperty, setTestProperty, NOTIFY testPropertyChanged) + Q_PRIVATE_QPROPERTY(d_func(), int, testProperty2, setTestProperty2, NOTIFY false) Q_PRIVATE_QPROPERTY(d_func(), int, lazyTestProperty, setLazyTestProperty, NOTIFY lazyTestPropertyChanged STORED false) Q_PRIVATE_QPROPERTIES_BEGIN Q_PRIVATE_QPROPERTY_IMPL(testProperty) + Q_PRIVATE_QPROPERTY_IMPL(testProperty2) Q_PRIVATE_QPROPERTY_IMPL(lazyTestProperty) Q_PRIVATE_QPROPERTIES_END @@ -4192,6 +4194,7 @@ public: void onTestPropertyChanged() { q->testPropertyChanged(); } QNotifiedProperty testProperty; + QProperty testProperty2; void onLazyTestPropertyChanged() { q->lazyTestPropertyChanged(); } @@ -4258,6 +4261,10 @@ void tst_Moc::privateQPropertyShim() testObject.setLazyTestProperty(400); QVERIFY(!testObject.lazyTestProperty.hasBinding()); QCOMPARE(testObject.lazyTestProperty(), 400); + + // mo generates correct code for plain QProperty in PIMPL + testObject.testProperty2.setValue(42); + QCOMPARE(testObject.testProperty2.value(), 42); } QTEST_MAIN(tst_Moc) -- cgit v1.2.3