Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/kernel/dguiapplicationhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1502,11 +1502,6 @@ bool DGuiApplicationHelper::setSingleInstance(const QString &key, DGuiApplicatio
}

socket_key += key;
QString lockfile = socket_key;
if (!lockfile.startsWith(QLatin1Char('/'))) {
lockfile = QDir::cleanPath(QDir::tempPath());
lockfile += QLatin1Char('/') + socket_key;
}

#ifdef Q_OS_LINUX
auto info = QFileInfo{"/proc/self/ns/pid"};
Expand All @@ -1527,11 +1522,17 @@ bool DGuiApplicationHelper::setSingleInstance(const QString &key, DGuiApplicatio
auto num = pidns.mid(start + 1, end - start - 1);

// append pid namespace
lockfile += QStringLiteral("_%1").arg(num);
socket_key += QStringLiteral("_%1").arg(num);
break;
}
#endif

QString lockfile = socket_key;
if (!lockfile.startsWith(QLatin1Char('/'))) {
lockfile = QDir::cleanPath(QDir::tempPath());
lockfile += QLatin1Char('/') + socket_key;
}

lockfile += QStringLiteral(".lock");
static QScopedPointer <QLockFile> lock(new QLockFile(lockfile));
// 同一个进程多次调用本接口使用最后一次设置的 key
Expand Down
Loading