summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2015-04-23 12:02:40 +0200
committerOlivier Goffart (Woboq GmbH) <ogoffart@woboq.com>2015-05-27 10:51:10 +0000
commit02f6b21bbc4f1f7afc30a87227c3a0787a5d2225 (patch)
treeb54e5f64cf94c021b8c695950a825ca99d363303 /tests
parent63660402d8d803b97c676395895c25e550c07f94 (diff)
QMetaType: Fix compilation with non default constructible Q_GADGET
Do not try to automatically register the meta type for Q_GADGET that are not default constructible. This fixes a source incompatibility in the function pointer syntax of QObject::connect when such types are used as an argument of a signal. Task-number: QTBUG-45721 Change-Id: I3065f6d57bc1f37e16988d2dee99118de250ca56 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp7
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp24
2 files changed, 30 insertions, 1 deletions
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index 691a4e819d..9cdb1f47f8 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -142,6 +142,11 @@ public:
class CustomGadget {
Q_GADGET
};
+class CustomGadget_NonDefaultConstructible {
+ Q_GADGET
+public:
+ CustomGadget_NonDefaultConstructible(int) {};
+};
class CustomNonQObject {};
class GadgetDerived : public CustomGadget {};
@@ -159,7 +164,7 @@ void tst_QMetaType::defined()
QVERIFY(!QMetaTypeId2<CustomQObject>::Defined);
QVERIFY(!QMetaTypeId2<CustomNonQObject>::Defined);
QVERIFY(!QMetaTypeId2<CustomNonQObject*>::Defined);
- QVERIFY(!QMetaTypeId2<CustomGadget*>::Defined);
+ QVERIFY(!QMetaTypeId2<CustomGadget_NonDefaultConstructible>::Defined);
}
struct Bar
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index 263cc5a07a..3ec84b5198 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -128,6 +128,7 @@ private slots:
void connectWithReference();
void connectManyArguments();
void connectForwardDeclare();
+ void connectNoDefaultConstructorArg();
void returnValue_data();
void returnValue();
void returnValue2_data();
@@ -5227,6 +5228,29 @@ void tst_QObject::connectForwardDeclare()
QVERIFY(connect(&ob, &ForwardDeclareArguments::mySignal, &ob, &ForwardDeclareArguments::mySlot, Qt::QueuedConnection));
}
+class NoDefaultConstructor
+{
+ Q_GADGET
+public:
+ NoDefaultConstructor(int) {}
+};
+
+class NoDefaultContructorArguments : public QObject
+{
+ Q_OBJECT
+signals:
+ void mySignal(const NoDefaultConstructor&);
+public slots:
+ void mySlot(const NoDefaultConstructor&) {}
+};
+
+void tst_QObject::connectNoDefaultConstructorArg()
+{
+ NoDefaultContructorArguments ob;
+ // it should compile
+ QVERIFY(connect(&ob, &NoDefaultContructorArguments::mySignal, &ob, &NoDefaultContructorArguments::mySlot, Qt::QueuedConnection));
+}
+
class ReturnValue : public QObject {
friend class tst_QObject;
Q_OBJECT