summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
diff options
context:
space:
mode:
authorSergio Martins <sergio.martins@kdab.com>2017-12-13 21:29:21 +0000
committerSérgio Martins <sergio.martins@kdab.com>2017-12-19 23:03:42 +0000
commit17d231039b53c03e67d025f1f72bbd529e98fcbd (patch)
tree5148d6e6722c24fd5bcfa5a4da86479c1d7037d5 /tests/auto/corelib/kernel/qobject/tst_qobject.cpp
parent77347a3699f8f236e1d440fb514ff8225ed5971b (diff)
Don't crash with null receiver/context in new-style connects
old style connects have protection against null sender and null receiver, but new style only had against null sender. Change-Id: Ie555ac078412918e60c3b60830fe1f3abfb7f5af Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto/corelib/kernel/qobject/tst_qobject.cpp')
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index 642d48d721..f1e58921c0 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -150,6 +150,7 @@ private slots:
void deleteLaterInAboutToBlockHandler();
void mutableFunctor();
void checkArgumentsForNarrowing();
+ void nullReceiver();
};
struct QObjectCreatedOnShutdown
@@ -7380,6 +7381,16 @@ void tst_QObject::checkArgumentsForNarrowing()
#undef FITS
}
+void tst_QObject::nullReceiver()
+{
+ QObject o;
+ QObject *nullObj = nullptr; // Passing nullptr directly doesn't compile with gcc 4.8
+ QVERIFY(!connect(&o, &QObject::destroyed, nullObj, &QObject::deleteLater));
+ QVERIFY(!connect(&o, &QObject::destroyed, nullObj, [] {}));
+ QVERIFY(!connect(&o, &QObject::destroyed, nullObj, Functor_noexcept()));
+ QVERIFY(!connect(&o, SIGNAL(destroyed()), nullObj, SLOT(deleteLater())));
+}
+
// Test for QtPrivate::HasQ_OBJECT_Macro
Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);