From f5222230a4bc936564ec73971b6eeefb01025094 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Wed, 4 Feb 2009 13:52:23 +0100 Subject: Fixes: QtSingleApplication: remove socket instance before listening RevBy: Thorbjorn Details: calls the newly introduced QLocalServer::removeServer() function before listening. The problem was: When the socket file was left there after the application quit (e.g. because of not closing it or when the app crashed), the first call to listen failed with "address already in use" error. Before, listen() would delete that file in that case, but that behavior changed and the "removeServer()" method introduced instead. --- src/shared/qtsingleapplication/qtlocalpeer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shared/qtsingleapplication/qtlocalpeer.cpp b/src/shared/qtsingleapplication/qtlocalpeer.cpp index 4b68c67c3d..452d43545a 100644 --- a/src/shared/qtsingleapplication/qtlocalpeer.cpp +++ b/src/shared/qtsingleapplication/qtlocalpeer.cpp @@ -94,9 +94,9 @@ bool QtLocalPeer::isClient() if (!lockFile.lock(QtLockedFile::WriteLock, false)) return true; + if (!QLocalServer::removeServer(socketName)) + qWarning("QtSingleCoreApplication: could not cleanup socket"); bool res = server->listen(socketName); - if (!res && server->serverError() == QAbstractSocket::AddressInUseError) - res = server->listen(socketName); // ### Workaround 4.4.0tp bug if (!res) qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString())); QObject::connect(server, SIGNAL(newConnection()), SLOT(receiveConnection())); -- cgit v1.2.3