Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qoperatingsystemversion_darwin.mm
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#
include
"qoperatingsystemversion_p.h"
5
6
#
import
<
Foundation
/
Foundation
.
h
>
7
8
#
include
<
QtCore
/
qfile
.
h
>
9
#
include
<
QtCore
/
qversionnumber
.
h
>
10
#
include
<
QtCore
/
private
/
qcore_mac_p
.
h
>
11
12
#
if
!
defined
(
QT_BOOTSTRAPPED
)
&&
QT_CONFIG
(
process
)
13
#
include
<
QtCore
/
qprocess
.
h
>
14
#
endif
15
16
QT_BEGIN_NAMESPACE
17
18
using
namespace
Qt::StringLiterals;
19
20
QOperatingSystemVersionBase
QOperatingSystemVersionBase
::current_impl()
21
{
22
QMacAutoReleasePool pool;
23
24
NSOperatingSystemVersion osv = NSProcessInfo.processInfo.operatingSystemVersion;
25
QVersionNumber versionNumber(osv.majorVersion, osv.minorVersion, osv.patchVersion);
26
27
if
(versionNumber.majorVersion() == 10 && versionNumber.minorVersion() >= 16) {
28
// The process is running in system version compatibility mode,
29
// due to the executable being built against a pre-macOS 11 SDK.
30
// This might happen even if we require a more recent SDK for
31
// building Qt applications, as the Qt 'app' might be a plugin
32
// hosted inside a host that used an earlier SDK. But, since we
33
// require a recent SDK for the Qt app itself, the application
34
// should be prepared for versions numbers beyond 10, and we can
35
// resolve the real version number here.
36
#
if
!
defined
(
QT_BOOTSTRAPPED
)
&&
QT_CONFIG
(
process
)
37
QProcess sysctl;
38
QProcessEnvironment nonCompatEnvironment;
39
nonCompatEnvironment.insert(
"SYSTEM_VERSION_COMPAT"_L1
,
"0"_L1
);
40
sysctl.setProcessEnvironment(nonCompatEnvironment);
41
sysctl.start(
"/usr/sbin/sysctl"_L1
, QStringList() <<
"-b"_L1
<<
"kern.osproductversion"_L1
);
42
if
(sysctl.waitForFinished()) {
43
auto
versionString = QString::fromLatin1(sysctl.readAll());
44
auto
nonCompatSystemVersion = QVersionNumber::fromString(versionString);
45
if
(!nonCompatSystemVersion.isNull())
46
versionNumber = nonCompatSystemVersion;
47
}
48
#
endif
49
}
50
51
QOperatingSystemVersionBase
operatingSystemVersion;
52
operatingSystemVersion.m_os =
currentType
(
)
;
53
operatingSystemVersion.m_major = versionNumber.majorVersion();
54
operatingSystemVersion.m_minor = versionNumber.minorVersion();
55
operatingSystemVersion.m_micro = versionNumber.microVersion();
56
57
return
operatingSystemVersion;
58
}
59
60
QT_END_NAMESPACE
QOperatingSystemVersionBase
Definition
qoperatingsystemversion.h:23
QOperatingSystemVersionBase::currentType
static constexpr OSType currentType()
Definition
qoperatingsystemversion.h:51
qtbase
src
corelib
global
qoperatingsystemversion_darwin.mm
Generated on
for Qt by
1.18.0