Skip to content

Commit

Permalink
QtSingleApplication: Clean up socket creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
gottcode committed Dec 5, 2018
1 parent 6504e14 commit 4b8f11f
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/qtsingleapplication/qtlocalpeer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,9 @@ bool QtLocalPeer::isClient()
if (!lockFile->tryLock(50))
return true;

bool res = server->listen(socketName);
#if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(4,5,0))
// ### Workaround
if (!res && server->serverError() == QAbstractSocket::AddressInUseError) {
QFile::remove(QDir::cleanPath(QDir::tempPath())+QLatin1Char('/')+socketName);
res = server->listen(socketName);
}
#endif
if (!res)
if (!QLocalServer::removeServer(socketName))
qWarning("QtSingleCoreApplication: could not clean up socket");
if (!server->listen(socketName))
qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString()));
QObject::connect(server, SIGNAL(newConnection()), SLOT(receiveConnection()));
return false;
Expand Down

0 comments on commit 4b8f11f

Please sign in to comment.