Skip to content

Commit

Permalink
Use qgetenv instead of QProcess/whoami to get username
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaski committed Aug 22, 2019
1 parent bd5ab80 commit 0105a53
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 26 deletions.
15 changes: 2 additions & 13 deletions 3rdparty/singleapplication/singleapplication_p.cpp
Expand Up @@ -32,8 +32,8 @@
#include <cstdlib>
#include <cstddef>

#include <QtGlobal>
#include <QtCore/QDir>
#include <QtCore/QProcess>
#include <QtCore/QByteArray>
#include <QtCore/QSemaphore>
#include <QtCore/QDataStream>
Expand Down Expand Up @@ -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
}

Expand Down
15 changes: 2 additions & 13 deletions 3rdparty/singleapplication/singlecoreapplication_p.cpp
Expand Up @@ -32,8 +32,8 @@
#include <cstdlib>
#include <cstddef>

#include <QtGlobal>
#include <QtCore/QDir>
#include <QtCore/QProcess>
#include <QtCore/QByteArray>
#include <QtCore/QSemaphore>
#include <QtCore/QDataStream>
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 0105a53

Please sign in to comment.