From ee4f1523497cb817dba06bb1002324c7157c6132 Mon Sep 17 00:00:00 2001 From: Andrei Smirnov Date: Fri, 6 Aug 2021 09:19:17 +0300 Subject: [PATCH] Fixing SingleInstance for *nix --- vendor/DOtherSide/lib/src/DOtherSideSingleInstance.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vendor/DOtherSide/lib/src/DOtherSideSingleInstance.cpp b/vendor/DOtherSide/lib/src/DOtherSideSingleInstance.cpp index c74cde964f..c5edcf21f5 100644 --- a/vendor/DOtherSide/lib/src/DOtherSideSingleInstance.cpp +++ b/vendor/DOtherSide/lib/src/DOtherSideSingleInstance.cpp @@ -20,6 +20,10 @@ SingleInstance::SingleInstance(const QString &uniqueName, QObject *parent) // note: this is an ad-hoc timeout value selected based on prior experience. if (!localSocket.waitForConnected(100)) { connect(m_localServer, &QLocalServer::newConnection, this, &SingleInstance::secondInstanceDetected); + // on *nix a crashed process will leave /tmp/xyz file preventing to start a new server. + // therefore, if we were unable to connect, then we assume the server died and we need to clean up. + // p.s. on Windows, this function does nothing. + QLocalServer::removeServer(socketName); if (!m_localServer->listen(socketName)) { qWarning() << "QLocalServer::listen(" << socketName << ") failed"; }