summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/configure.json2
-rw-r--r--src/corelib/io/io.pri2
-rw-r--r--src/corelib/io/qprocess_darwin.mm58
-rw-r--r--src/corelib/io/qprocess_unix.cpp15
4 files changed, 63 insertions, 14 deletions
diff --git a/src/corelib/configure.json b/src/corelib/configure.json
index 6faedb6051..d4a511781c 100644
--- a/src/corelib/configure.json
+++ b/src/corelib/configure.json
@@ -449,7 +449,7 @@
"label": "QProcessEnvironment",
"purpose": "Provides a higher-level abstraction of environment variables.",
"section": "File I/O",
- "condition": "!config.winrt && !config.uikit && !config.integrity && !config.vxworks",
+ "condition": "!config.winrt && !config.integrity",
"output": [ "publicFeature" ]
},
"temporaryfile": {
diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri
index 0414ae966a..78416cdf5e 100644
--- a/src/corelib/io/io.pri
+++ b/src/corelib/io/io.pri
@@ -146,6 +146,8 @@ win32 {
}
mac {
SOURCES += io/qstorageinfo_mac.cpp
+ qtConfig(processenvironment): \
+ OBJECTIVE_SOURCES += io/qprocess_darwin.mm
OBJECTIVE_SOURCES += io/qstandardpaths_mac.mm
osx {
OBJECTIVE_SOURCES += io/qfilesystemwatcher_fsevents.mm
diff --git a/src/corelib/io/qprocess_darwin.mm b/src/corelib/io/qprocess_darwin.mm
new file mode 100644
index 0000000000..dd7a8275b9
--- /dev/null
+++ b/src/corelib/io/qprocess_darwin.mm
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <private/qprocess_p.h>
+
+#import <Foundation/Foundation.h>
+
+QT_BEGIN_NAMESPACE
+
+QProcessEnvironment QProcessEnvironment::systemEnvironment()
+{
+ __block QProcessEnvironment env;
+ [[[NSProcessInfo processInfo] environment]
+ enumerateKeysAndObjectsUsingBlock:^(NSString *name, NSString *value, BOOL *__unused stop) {
+ env.d->hash.insert(
+ QProcessEnvironmentPrivate::Key(QString::fromNSString(name).toLocal8Bit()),
+ QProcessEnvironmentPrivate::Value(QString::fromNSString(value).toLocal8Bit()));
+ }];
+ return env;
+}
+
+QT_END_NAMESPACE
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 39ec370d9c..deca5c50ff 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -119,21 +119,11 @@ QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
-#if QT_CONFIG(processenvironment)
-
-QT_BEGIN_INCLUDE_NAMESPACE
-#if defined(Q_OS_MACOS)
-# include <crt_externs.h>
-# define environ (*_NSGetEnviron())
-#else
-extern char **environ;
-#endif
-QT_END_INCLUDE_NAMESPACE
+#if QT_CONFIG(processenvironment) && !defined(Q_OS_DARWIN)
QProcessEnvironment QProcessEnvironment::systemEnvironment()
{
QProcessEnvironment env;
-#if !defined(QT_PLATFORM_UIKIT)
const char *entry;
for (int count = 0; (entry = environ[count]); ++count) {
const char *equal = strchr(entry, '=');
@@ -145,11 +135,10 @@ QProcessEnvironment QProcessEnvironment::systemEnvironment()
env.d->hash.insert(QProcessEnvironmentPrivate::Key(name),
QProcessEnvironmentPrivate::Value(value));
}
-#endif
return env;
}
-#endif // QT_CONFIG(processenvironment)
+#endif // QT_CONFIG(processenvironment) && !defined(Q_OS_DARWIN)
#if QT_CONFIG(process)