Core: Maintain the lock while reading config file

This commit is contained in:
Pieter Hijma
2024-05-17 11:29:49 +02:00
parent 281230c520
commit 1f3f14740e

View File

@@ -1747,12 +1747,6 @@ int getTimeout()
const int timeout = 5000;
return timeout;
}
bool waitForReadAccess(const Base::FileInfo& file)
{
QLockFile lock(getLockFile(file));
return lock.tryLock(getTimeout());
}
} // namespace
//**************************************************************************
@@ -1774,7 +1768,8 @@ int ParameterManager::LoadDocument(const char* sFileName)
{
try {
Base::FileInfo file(sFileName);
if (!waitForReadAccess(file)) {
QLockFile lock(getLockFile(file));
if (!lock.tryLock(getTimeout())) {
// Continue with empty config
CreateDocument();
SetIgnoreSave(true);