Commit f5222230 authored by Peter Hartmann's avatar Peter Hartmann
Browse files

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.
parent 6f4a8be9
......@@ -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()));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment