mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 20:44:15 +00:00
Compilation fix on Windows (getuid missing)
This commit is contained in:
parent
fb874695c9
commit
a98a002d57
14
src/GUI.cpp
14
src/GUI.cpp
@ -66,6 +66,10 @@
|
|||||||
#include "propertieswidget.h"
|
#include "propertieswidget.h"
|
||||||
#include "statusbar.h"
|
#include "statusbar.h"
|
||||||
|
|
||||||
|
#ifdef W_WS_WIN
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
|
|
||||||
#define TIME_TRAY_BALLOON 5000
|
#define TIME_TRAY_BALLOON 5000
|
||||||
@ -161,7 +165,15 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
|
|||||||
processParams(torrentCmdLine);
|
processParams(torrentCmdLine);
|
||||||
// Use a tcp server to allow only one instance of qBittorrent
|
// Use a tcp server to allow only one instance of qBittorrent
|
||||||
localServer = new QLocalServer();
|
localServer = new QLocalServer();
|
||||||
QString uid = QString::number(getuid());
|
QString uid = "";
|
||||||
|
#ifdef Q_WS_WIN
|
||||||
|
char buffer[255] = {0};
|
||||||
|
DWORD buffer_len;
|
||||||
|
if (!GetUserName(buffer, &buffer_len))
|
||||||
|
uid = QString(buffer)
|
||||||
|
#else
|
||||||
|
uid = QString::number(getuid());
|
||||||
|
#endif
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
if(QFile::exists(QDir::tempPath()+QDir::separator()+QString("qBittorrent-")+uid)) {
|
if(QFile::exists(QDir::tempPath()+QDir::separator()+QString("qBittorrent-")+uid)) {
|
||||||
// Socket was not closed cleanly
|
// Socket was not closed cleanly
|
||||||
|
13
src/main.cpp
13
src/main.cpp
@ -57,6 +57,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
#include "stacktrace.h"
|
#include "stacktrace.h"
|
||||||
|
#else
|
||||||
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -169,7 +171,6 @@ void useStyle(QApplication *app, QString style){
|
|||||||
|
|
||||||
// Main
|
// Main
|
||||||
int main(int argc, char *argv[]){
|
int main(int argc, char *argv[]){
|
||||||
QFile file;
|
|
||||||
QString locale;
|
QString locale;
|
||||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||||
#ifndef DISABLE_GUI
|
#ifndef DISABLE_GUI
|
||||||
@ -178,7 +179,15 @@ int main(int argc, char *argv[]){
|
|||||||
|
|
||||||
//Check if there is another instance running
|
//Check if there is another instance running
|
||||||
QLocalSocket localSocket;
|
QLocalSocket localSocket;
|
||||||
QString uid = QString::number(getuid());
|
QString uid;
|
||||||
|
#ifdef Q_WS_WIN
|
||||||
|
char buffer[255] = {0};
|
||||||
|
DWORD buffer_len;
|
||||||
|
if (!GetUserName(buffer, &buffer_len))
|
||||||
|
uid = QString(buffer)
|
||||||
|
#else
|
||||||
|
uid = QString::number(getuid());
|
||||||
|
#endif
|
||||||
localSocket.connectToServer("qBittorrent-"+uid, QIODevice::WriteOnly);
|
localSocket.connectToServer("qBittorrent-"+uid, QIODevice::WriteOnly);
|
||||||
if (localSocket.waitForConnected(1000)){
|
if (localSocket.waitForConnected(1000)){
|
||||||
std::cout << "Another qBittorrent instance is already running...\n";
|
std::cout << "Another qBittorrent instance is already running...\n";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user