Skip to content

Commit

Permalink
Attempt to make the directories before trying to lock the lockfile.
Browse files Browse the repository at this point in the history
In a fresh installation where the `.ini` file does not yet exist, the
application could wronly determine that another instance was running as
the lockfile could not be created due to the missing parent directory.

All the intermediate-level directories needed to contain the lockfile
are now created if they did not exist.
  • Loading branch information
cristian64 committed May 18, 2024
1 parent bd8f6b0 commit e9cb2be
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Source/GUI/Settings/SConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#include <iostream>

#include <qcoreapplication.h>
#include <QDir>
#include <qfile.h>
#include <QFileInfo>

namespace
{
Expand Down Expand Up @@ -32,6 +34,7 @@ SConfig::SConfig()
}

const QString lockFilepath{m_settings->fileName() + "_lock"};
QDir().mkpath(QFileInfo{lockFilepath}.absolutePath());
m_lockFile = std::make_unique<QLockFile>(lockFilepath);
if (!m_lockFile->tryLock())
{
Expand Down

0 comments on commit e9cb2be

Please sign in to comment.