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) <ogoffart@woboq.com>bb10
parent
8c427e5bdf
commit
b6eea89b67
|
|
@ -136,6 +136,8 @@ static QBasicMutex fcntlLock;
|
|||
static bool fcntlWorksAfterFlock(const QString &fn)
|
||||
{
|
||||
QMutexLocker lock(&fcntlLock);
|
||||
if (fcntlOK.isDestroyed())
|
||||
return QLockFilePrivate::checkFcntlWorksAfterFlock(fn);
|
||||
bool *worksPtr = fcntlOK->object(fn);
|
||||
if (!worksPtr) {
|
||||
worksPtr = new bool(QLockFilePrivate::checkFcntlWorksAfterFlock(fn));
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in New Issue