From b6eea89b67e0d3bb4f8f888fff21257eff0b65a5 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 3 Apr 2016 18:36:52 +0200 Subject: Fix crash when using QLockFile in a global destructor (for instance any global object which writes out to a config file in the destructor). If the global cache isn't available anymore, don't use it. Change-Id: I851a6e394d0b073aebf3ffd88b1966d424bfb92e Reviewed-by: Olivier Goffart (Woboq GmbH) --- tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/auto/corelib/io/qlockfile') diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp index 21c5696d1d..4884c126d4 100644 --- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp +++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp @@ -546,5 +546,15 @@ bool tst_QLockFile::overwritePidInLockFile(const QString &filePath, qint64 pid) return f.write(buf) == buf.size(); } +struct LockFileUsageInGlobalDtor +{ + ~LockFileUsageInGlobalDtor() { + QLockFile lockFile(QDir::currentPath() + "/lastlock"); + QVERIFY(lockFile.lock()); + QVERIFY(lockFile.isLocked()); + } +}; +LockFileUsageInGlobalDtor s_instance; + QTEST_MAIN(tst_QLockFile) #include "tst_qlockfile.moc" -- cgit v1.2.3