diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index d3200ba42c..4957f7de67 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2013 Olivier Goffart ** Contact: http://www.qt-project.org/ ** ** This file is part of the tools applications of the Qt Toolkit. @@ -896,7 +897,7 @@ void Generator::generateMetacall() for (int i = 0; i < cdef->propertyList.size(); ++i) { const PropertyDef &p = cdef->propertyList.at(i); needGet |= !p.read.isEmpty() || !p.member.isEmpty(); - if (!p.read.isEmpty()) + if (!p.read.isEmpty() || !p.member.isEmpty()) needTempVarForGet |= (p.gspec != PropertyDef::PointerSpec && p.gspec != PropertyDef::ReferenceSpec); diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index af77e5c3ad..195361e007 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -547,7 +547,7 @@ private slots: void returnRefs(); void memberProperties_data(); void memberProperties(); - + void memberProperties2(); void privateSignalConnection(); void finalClasses_data(); void finalClasses(); @@ -1893,6 +1893,23 @@ void tst_Moc::memberProperties() } } +//this used to fail to compile +class ClassWithOneMember : public QObject { + Q_PROPERTY(int member MEMBER member) + Q_OBJECT +public: + int member; +}; + +void tst_Moc::memberProperties2() +{ + ClassWithOneMember o; + o.member = 442; + QCOMPARE(o.property("member").toInt(), 442); + QVERIFY(o.setProperty("member", 6666)); + QCOMPARE(o.member, 6666); +} + class SignalConnectionTester : public QObject { Q_OBJECT