From 5e3be2591684ffb6a027b847a7c47ed2f89c03b0 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Wed, 29 Oct 2008 19:58:44 +0000 Subject: [PATCH] - Single instance code is now more reliable on Qt >= 4.4 (closes #286968) --- Changelog | 1 + src/GUI.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index c922ad08f..e446c86c0 100644 --- a/Changelog +++ b/Changelog @@ -10,6 +10,7 @@ - BUGFIX: Disable ETA calculation when ETA column is hidden - BUGFIX: Removed "disconnected" connection state, detection was far from perfect - BUGFIX: Torrents are no longer starting from scratch when changing default save path (when torrent addition dialog is disabled) + - BUGFIX: Single instance code is now more reliable on Qt >= 4.4 - COSMETIC: Transfer speed, ratio, connection status and DHT nodes are displayed in status bar - COSMETIC: RSS Tab is now hidden as a default - COSMETIC: Allow to hide or display top toolbar diff --git a/src/GUI.cpp b/src/GUI.cpp index 2dcd3e615..6c4c835a6 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -181,6 +181,13 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis #ifdef QT_4_4 localServer = new QLocalServer(); QString uid = QString::number(getuid()); +#ifdef Q_WS_X11 + if(QFile::exists(QDir::tempPath()+QDir::separator()+QString("qBittorrent-")+uid)) { + // Socket was not closed cleanly + std::cerr << "Warning: Local domain socket was not closed cleanly, deleting file...\n"; + QFile::remove(QDir::tempPath()+QDir::separator()+QString("qBittorrent-")+uid); + } +#endif if (!localServer->listen("qBittorrent-"+uid)) { #else localServer = new QTcpServer(); @@ -188,7 +195,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis #endif std::cerr << "Couldn't create socket, single instance mode won't work...\n"; } -#ifndef QT_4_4 +#ifndef QT_4_4 else { QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); settings.setValue(QString::fromUtf8("uniqueInstancePort"), localServer->serverPort());