From 0105a537656fea4ba2d35b92de511ced56f5ed0a Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Thu, 22 Aug 2019 21:38:54 +0200 Subject: [PATCH] Use qgetenv instead of QProcess/whoami to get username --- .../singleapplication/singleapplication_p.cpp | 15 ++------------- .../singleapplication/singlecoreapplication_p.cpp | 15 ++------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/3rdparty/singleapplication/singleapplication_p.cpp b/3rdparty/singleapplication/singleapplication_p.cpp index de4945e5d..f556b697e 100644 --- a/3rdparty/singleapplication/singleapplication_p.cpp +++ b/3rdparty/singleapplication/singleapplication_p.cpp @@ -32,8 +32,8 @@ #include #include +#include #include -#include #include #include #include @@ -113,18 +113,7 @@ void SingleApplicationPrivate::genBlockServerName() } #endif #ifdef Q_OS_UNIX - QProcess process; - process.start( "whoami" ); - if( process.waitForFinished( 100 ) && - process.exitCode() == QProcess::NormalExit) { - appData.addData( process.readLine() ); - } else { - appData.addData( - QDir( - QStandardPaths::standardLocations( QStandardPaths::HomeLocation ).first() - ).absolutePath().toUtf8() - ); - } + appData.addData(qgetenv("USER")); #endif } diff --git a/3rdparty/singleapplication/singlecoreapplication_p.cpp b/3rdparty/singleapplication/singlecoreapplication_p.cpp index 20de2ef24..cd4d3ed74 100644 --- a/3rdparty/singleapplication/singlecoreapplication_p.cpp +++ b/3rdparty/singleapplication/singlecoreapplication_p.cpp @@ -32,8 +32,8 @@ #include #include +#include #include -#include #include #include #include @@ -113,18 +113,7 @@ void SingleCoreApplicationPrivate::genBlockServerName() } #endif #ifdef Q_OS_UNIX - QProcess process; - process.start( "whoami" ); - if( process.waitForFinished( 100 ) && - process.exitCode() == QProcess::NormalExit) { - appData.addData( process.readLine() ); - } else { - appData.addData( - QDir( - QStandardPaths::standardLocations( QStandardPaths::HomeLocation ).first() - ).absolutePath().toUtf8() - ); - } + appData.addData(qgetenv("USER")); #endif }