diff --git a/src/corelib/ipc/qtipccommon.cpp b/src/corelib/ipc/qtipccommon.cpp index 050c79c6290..34c13e7a5cb 100644 --- a/src/corelib/ipc/qtipccommon.cpp +++ b/src/corelib/ipc/qtipccommon.cpp @@ -85,6 +85,33 @@ static QNativeIpcKey::Type stringToType(QStringView typeString) return QNativeIpcKey::Type{}; } +#if defined(Q_OS_DARWIN) || defined(QT_BUILD_INTERNAL) +/*! + \internal + + Returns whether this IPC type \a ipcType and key type \a keyType is + supported on the current machine, with a runtime check. +*/ +bool QtIpcCommon::isIpcSupportedAtRuntime(IpcType ipcType, QNativeIpcKey::Type keyType) +{ + switch (keyType) { + case QNativeIpcKey::Type::SystemV: + break; + + case QNativeIpcKey::Type::PosixRealtime: + case QNativeIpcKey::Type::Windows: + return isIpcSupported(ipcType, keyType); + } + +# if defined(Q_OS_DARWIN) + // System V IPC is not supported on Apple platforms if the application is + // currently running in a sandbox. + return !qt_apple_isSandboxed(); +# endif + return isIpcSupported(ipcType, keyType); +} +#endif + /*! \internal diff --git a/src/corelib/ipc/qtipccommon_p.h b/src/corelib/ipc/qtipccommon_p.h index fe9900a80d1..32891905d78 100644 --- a/src/corelib/ipc/qtipccommon_p.h +++ b/src/corelib/ipc/qtipccommon_p.h @@ -57,6 +57,11 @@ static constexpr bool isIpcSupported(IpcType ipcType, QNativeIpcKey::Type type) return QT_CONFIG(sysv_shm); return QT_CONFIG(sysv_sem); } +#if defined(Q_OS_DARWIN) || defined(QT_BUILD_INTERNAL) +bool isIpcSupportedAtRuntime(IpcType type, QNativeIpcKey::Type); +#else +static constexpr auto isIpcSupportedAtRuntime = isIpcSupported; +#endif Q_AUTOTEST_EXPORT QString legacyPlatformSafeKey(const QString &key, IpcType ipcType,