summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2012-04-11 14:10:12 +0200
committerQt by Nokia <qt-info@nokia.com>2012-04-13 08:33:34 +0200
commitd1329e43cbb243f3b28d172569befc0c28f49b8b (patch)
tree88af164c7c95d29bf5075a1f39015fbb3a7fde91 /tests
parent53112c51674680a55bcf3104352175528af19e9f (diff)
moc: fix compilation of signals returning pointers.
That was a regression introduced in 1c5db1aff Example: signals: int *someSignal(); would produce this code: int* _t0 = int*(); which does not compile So have special handling for pointer to change it to '= 0' Change-Id: Ie695e15e309d15c3cfd5c5a69ac8bf6d61ae9915 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index a6ad1d53bc..f7f13e65ea 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -4904,6 +4904,8 @@ signals:
int returnInt(int);
void returnVoid(int);
CustomType returnCustomType(int);
+
+ QObject *returnPointer();
public slots:
QVariant returnVariantSlot(int i) { return i; }
QString returnStringSlot(int i) { return QString::number(i); }
@@ -4912,6 +4914,8 @@ public slots:
void returnVoidSlot() {}
int return23() { return 23; }
QString returnHello() { return QStringLiteral("hello"); }
+ QObject *returnThisSlot1() { return this; }
+ ReturnValue *returnThisSlot2() { return this; }
public:
struct VariantFunctor {
QVariant operator()(int i) { return i; }
@@ -4964,6 +4968,7 @@ void tst_QObject::returnValue()
QCOMPARE(emit r.returnInt(45), int());
emit r.returnVoid(45);
QCOMPARE((emit r.returnCustomType(45)).value(), CustomType().value());
+ QCOMPARE((emit r.returnPointer()), static_cast<QObject *>(0));
}
{ // connected to a slot returning the same type
CheckInstanceCount checker;
@@ -4976,6 +4981,8 @@ void tst_QObject::returnValue()
QCOMPARE(emit r.returnInt(45), int(45));
QVERIFY(connect(&r, &ReturnValue::returnCustomType, &receiver, &ReturnValue::returnCustomTypeSlot, type));
QCOMPARE((emit r.returnCustomType(45)).value(), CustomType(45).value());
+ QVERIFY(connect(&r, &ReturnValue::returnPointer, &receiver, &ReturnValue::returnThisSlot1, type));
+ QCOMPARE((emit r.returnPointer()), static_cast<QObject *>(&receiver));
}
if (!isBlockingQueued) { // connected to simple functions or functor
CheckInstanceCount checker;
@@ -5004,6 +5011,8 @@ void tst_QObject::returnValue()
QCOMPARE((emit r.returnCustomType(48)).value(), CustomType(48).value());
QVERIFY(connect(&r, &ReturnValue::returnVoid, &receiver, &ReturnValue::returnCustomTypeSlot, type));
emit r.returnVoid(48);
+ QVERIFY(connect(&r, &ReturnValue::returnPointer, &receiver, &ReturnValue::returnThisSlot2, type));
+ QCOMPARE((emit r.returnPointer()), static_cast<QObject *>(&receiver));
}
if (!isBlockingQueued) { // connected to functor with different type
CheckInstanceCount checker;
@@ -5028,6 +5037,8 @@ void tst_QObject::returnValue()
QCOMPARE(emit r.returnInt(45), int());
QVERIFY(connect(&r, &ReturnValue::returnCustomType, &receiver, &ReturnValue::returnVoidSlot, type));
QCOMPARE((emit r.returnCustomType(45)).value(), CustomType().value());
+ QVERIFY(connect(&r, &ReturnValue::returnPointer, &receiver, &ReturnValue::returnVoidSlot, type));
+ QCOMPARE((emit r.returnPointer()), static_cast<QObject *>(0));
}
if (!isBlockingQueued) {
// queued connection should not forward the return value
@@ -5041,6 +5052,9 @@ void tst_QObject::returnValue()
QCOMPARE(emit r.returnInt(45), int());
QVERIFY(connect(&r, &ReturnValue::returnCustomType, &receiver, &ReturnValue::returnCustomTypeSlot, Qt::QueuedConnection));
QCOMPARE((emit r.returnCustomType(45)).value(), CustomType().value());
+ QVERIFY(connect(&r, &ReturnValue::returnPointer, &receiver, &ReturnValue::returnThisSlot1, Qt::QueuedConnection));
+ QCOMPARE((emit r.returnPointer()), static_cast<QObject *>(0));
+
QCoreApplication::processEvents();
QVERIFY(connect(&r, &ReturnValue::returnVariant, &receiver, &ReturnValue::returnStringSlot, Qt::QueuedConnection));