Commit 98adc59f authored by Kurt Hindenburg's avatar Kurt Hindenburg
Browse files

Check for getpwuid function instead of OS; const ref for loop

Various update to fa398f56

The TerminalInterfaceTest fails since fa398f56.
parent d351756c
......@@ -65,6 +65,8 @@ if(NOT APPLE)
endif()
set(HAVE_X11 ${X11_FOUND})
check_function_exists (getpwuid HAVE_GETPWUID)
# See above includes for defaults
add_definitions(
-DQT_NO_FOREACH
......
......@@ -49,7 +49,7 @@
#include "terminalDisplay/TerminalScrollBar.hpp"
// Linux
#ifdef Q_OS_LINUX
#ifdef HAVE_GETPWUID
#include <sys/types.h>
#include <pwd.h>
#endif
......@@ -452,17 +452,17 @@ void Session::run()
QStringList programs = {_program, QString::fromUtf8(qgetenv("SHELL")), QStringLiteral("/bin/sh")};
#ifdef Q_OS_LINUX
#ifdef HAVE_GETPWUID
auto pw = getpwuid(getuid());
// pw may be NULL
if (pw != NULL) {
if (pw != nullptr) {
programs.insert(1, QString::fromLocal8Bit(pw->pw_shell));
}
// we don't need to and shouldn't free pw
// pw: Do not pass the returned pointer to free.
#endif
QString exec;
for (auto choice : programs) {
for (const auto &choice : programs) {
exec = checkProgram(choice);
if (!exec.isEmpty()) {
break;
......
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