summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-12-23 15:16:08 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-24 08:10:16 +0100
commit2b287c7c210ac708c0f8872e51517e0d46380ad3 (patch)
tree42a127faabe1318db2ef18cfdd7dc1ffc6ab58e5 /tests
parentd776937df91e46536f404c6868d64016b6038d7b (diff)
Fix regression in property handling with enums from gadgets
When declaring a Q_PROPERTY(SomeType::SomeEnum foo ...) and SomeType is not a QObject but a gadget, then we must still include SomeType's meta object in the list of related meta objects. Task-number: QTBUG-35657 Change-Id: I46195140cb5d180c4f03bb1fe06a876e3fe11267 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/tools/moc/moc.pro4
-rw-r--r--tests/auto/tools/moc/qtbug-35657-gadget.h51
-rw-r--r--tests/auto/tools/moc/related-metaobjects-in-gadget.h54
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp11
4 files changed, 119 insertions, 1 deletions
diff --git a/tests/auto/tools/moc/moc.pro b/tests/auto/tools/moc/moc.pro
index c68d48b813..320887637d 100644
--- a/tests/auto/tools/moc/moc.pro
+++ b/tests/auto/tools/moc/moc.pro
@@ -25,7 +25,9 @@ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-n
function-with-attributes.h \
plugin_metadata.h \
single-quote-digit-separator-n3781.h \
- related-metaobjects-in-namespaces.h
+ related-metaobjects-in-namespaces.h \
+ qtbug-35657-gadget.h \
+ related-metaobjects-in-gadget.h
if(*-g++*|*-icc*|*-clang*|*-llvm):!irix-*:!win32-*: HEADERS += os9-newlines.h win-newlines.h
diff --git a/tests/auto/tools/moc/qtbug-35657-gadget.h b/tests/auto/tools/moc/qtbug-35657-gadget.h
new file mode 100644
index 0000000000..1f25ce1b1d
--- /dev/null
+++ b/tests/auto/tools/moc/qtbug-35657-gadget.h
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QObject>
+
+namespace QTBUG_35657 {
+ class A {
+ Q_GADGET
+ Q_ENUMS(SomeEnum)
+ public:
+ enum SomeEnum { SomeEnumValue = 0 };
+ };
+}
diff --git a/tests/auto/tools/moc/related-metaobjects-in-gadget.h b/tests/auto/tools/moc/related-metaobjects-in-gadget.h
new file mode 100644
index 0000000000..5665a79251
--- /dev/null
+++ b/tests/auto/tools/moc/related-metaobjects-in-gadget.h
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QObject>
+#include "qtbug-35657-gadget.h"
+
+namespace QTBUG_35657 {
+ class B : public QObject
+ {
+ Q_OBJECT
+ Q_PROPERTY(A::SomeEnum blah READ blah)
+ public:
+
+ A::SomeEnum blah() const { return A::SomeEnumValue; }
+ };
+}
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index 46f3e5a42a..e0e6129075 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -77,6 +77,7 @@
#include "parse-defines.h"
#include "related-metaobjects-in-namespaces.h"
+#include "related-metaobjects-in-gadget.h"
QT_USE_NAMESPACE
@@ -571,6 +572,7 @@ private slots:
void QTBUG32933_relatedObjectsDontIncludeItself();
void writeEnumFromUnrelatedClass();
void relatedMetaObjectsWithinNamespaces();
+ void relatedMetaObjectsInGadget();
signals:
void sigWithUnsignedArg(unsigned foo);
@@ -3162,6 +3164,15 @@ void tst_Moc::relatedMetaObjectsWithinNamespaces()
QVERIFY(testMo->d.relatedMetaObjects[0] == relatedMo);
}
+void tst_Moc::relatedMetaObjectsInGadget()
+{
+ const QMetaObject *relatedMo = &QTBUG_35657::A::staticMetaObject;
+
+ const QMetaObject *testMo = &QTBUG_35657::B::staticMetaObject;
+ QVERIFY(testMo->d.relatedMetaObjects);
+ QVERIFY(testMo->d.relatedMetaObjects[0] == relatedMo);
+}
+
QTEST_MAIN(tst_Moc)
// the generated code must compile with QT_NO_KEYWORDS