From aebb9f89d12bdfcab3fcb0f050db27df5a712cc5 Mon Sep 17 00:00:00 2001 From: brvphoenix <30111323+brvphoenix@users.noreply.github.com> Date: Sun, 23 May 2021 14:29:41 +0800 Subject: [PATCH] Remove the lockfile on exit (#14997) --- src/app/qtlocalpeer/qtlocalpeer.cpp | 6 ++++++ src/app/qtlocalpeer/qtlocalpeer.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/app/qtlocalpeer/qtlocalpeer.cpp b/src/app/qtlocalpeer/qtlocalpeer.cpp index 5a83963cb..3e7b25517 100644 --- a/src/app/qtlocalpeer/qtlocalpeer.cpp +++ b/src/app/qtlocalpeer/qtlocalpeer.cpp @@ -134,6 +134,12 @@ QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId) lockFile.open(QIODevice::ReadWrite); } +QtLocalPeer::~QtLocalPeer() +{ + lockFile.unlock(); + lockFile.remove(); +} + bool QtLocalPeer::isClient() { if (lockFile.isLocked()) diff --git a/src/app/qtlocalpeer/qtlocalpeer.h b/src/app/qtlocalpeer/qtlocalpeer.h index 32f9a2f15..51954cfc2 100644 --- a/src/app/qtlocalpeer/qtlocalpeer.h +++ b/src/app/qtlocalpeer/qtlocalpeer.h @@ -78,6 +78,7 @@ class QtLocalPeer : public QObject public: QtLocalPeer(QObject *parent = nullptr, const QString &appId = QString()); + ~QtLocalPeer() override; bool isClient(); bool sendMessage(const QString &message, int timeout);