summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/global/qglobal/tst_qglobal.cpp7
-rw-r--r--tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp16
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp42
3 files changed, 65 insertions, 0 deletions
diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
index 0d08e912f8..4eb3e4fc98 100644
--- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
+++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
@@ -101,6 +101,13 @@ void tst_QGlobal::for_each()
QCOMPARE(i, counter++);
}
QCOMPARE(counter, list.count());
+
+ // check whether we can pass a constructor as container argument
+ counter = 0;
+ foreach (int i, QList<int>(list)) {
+ QCOMPARE(i, counter++);
+ }
+ QCOMPARE(counter, list.count());
}
void tst_QGlobal::qassert()
diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
index 20a31fc98f..7247b02498 100644
--- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
+++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
@@ -77,6 +77,7 @@ private slots:
void testAllWritableLocations_data();
void testAllWritableLocations();
void testCleanPath();
+ void testXdgPathCleanup();
private:
#ifdef Q_XDG_PLATFORM
@@ -477,6 +478,8 @@ void tst_qstandardpaths::testAllWritableLocations()
QString loc = QStandardPaths::writableLocation(location);
if (loc.size() > 1) // workaround for unlikely case of locations that return '/'
QCOMPARE(loc.endsWith(QLatin1Char('/')), false);
+ QVERIFY(loc.contains(QLatin1Char('/')));
+ QVERIFY(!loc.contains(QLatin1Char('\\')));
}
void tst_qstandardpaths::testCleanPath()
@@ -491,6 +494,19 @@ void tst_qstandardpaths::testCleanPath()
}
}
+void tst_qstandardpaths::testXdgPathCleanup()
+{
+#ifdef Q_XDG_PLATFORM
+ setCustomLocations();
+ const QString uncleanGlobalAppDir = "/./" + QFile::encodeName(m_globalAppDir);
+ qputenv("XDG_DATA_DIRS", QFile::encodeName(uncleanGlobalAppDir) + "::relative/path");
+ const QStringList appsDirs = QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation);
+ QVERIFY(!appsDirs.contains("/applications"));
+ QVERIFY(!appsDirs.contains(uncleanGlobalAppDir + "/applications"));
+ QVERIFY(!appsDirs.contains("relative/path/applications"));
+#endif
+}
+
QTEST_MAIN(tst_qstandardpaths)
#include "tst_qstandardpaths.moc"
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index ac8aae8d3a..1c0a495116 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -147,6 +147,7 @@ private slots:
void connectFunctorOverloads();
void connectFunctorQueued();
void connectFunctorWithContext();
+ void connectFunctorDeadlock();
void connectStaticSlotWithObject();
void disconnectDoesNotLeakFunctor();
void contextDoesNotLeakFunctor();
@@ -5740,6 +5741,47 @@ void tst_QObject::connectFunctorWithContext()
context->deleteLater();
}
+class MyFunctor
+{
+public:
+ explicit MyFunctor(QObject *objectToDisconnect)
+ : m_objectToDisconnect(objectToDisconnect)
+ {}
+
+ ~MyFunctor() {
+ // Do operations that will lock the internal signalSlotLock mutex on many QObjects.
+ // The more QObjects, the higher the chance that the signalSlotLock mutex used
+ // is already in use. If the number of objects is higher than the number of mutexes in
+ // the pool (currently 131), the deadlock should always trigger. Use an even higher number
+ // to be on the safe side.
+ const int objectCount = 1024;
+ SenderObject lotsOfObjects[objectCount];
+ for (int i = 0; i < objectCount; ++i) {
+ QObject::connect(&lotsOfObjects[i], &SenderObject::signal1,
+ &lotsOfObjects[i], &SenderObject::aPublicSlot);
+ }
+ }
+
+ void operator()() {
+ // This will cause the slot object associated with this functor to be destroyed after
+ // this function returns. That in turn will destroy this functor.
+ // If our dtor runs with the signalSlotLock held, the bunch of connect()
+ // performed there will deadlock trying to lock that lock again.
+ m_objectToDisconnect->disconnect();
+ }
+
+private:
+ QObject *m_objectToDisconnect;
+};
+
+void tst_QObject::connectFunctorDeadlock()
+{
+ SenderObject sender;
+ MyFunctor functor(&sender);
+ QObject::connect(&sender, &SenderObject::signal1, functor);
+ sender.emitSignal1();
+}
+
static int s_static_slot_checker = 1;
class StaticSlotChecker : public QObject