From ea8e5180ff75b059bb0e742b7825fd9af440f3ee Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Tue, 7 Mar 2023 23:04:00 +0100 Subject: [PATCH] Detect if running under Rosetta --- src/core/mainwindow.cpp | 5 +++-- src/utilities/macosutils.h | 1 + src/utilities/macosutils.mm | 12 ++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/core/mainwindow.cpp b/src/core/mainwindow.cpp index 484d58bf7..4c38d5190 100644 --- a/src/core/mainwindow.cpp +++ b/src/core/mainwindow.cpp @@ -94,6 +94,7 @@ #ifdef Q_OS_MACOS # include "mac_startup.h" # include "macsystemtrayicon.h" +# include "utilities/macosutils.h" #else # include "qtsystemtrayicon.h" #endif @@ -1038,10 +1039,10 @@ MainWindow::MainWindow(Application *app, std::shared_ptr tray_ic #endif #if defined(Q_OS_MACOS) - if (QSysInfo::buildCpuArchitecture() != QSysInfo::currentCpuArchitecture()) { + if (Utilities::ProcessTranslated()) { QErrorMessage *error_message = new QErrorMessage; error_message->setAttribute(Qt::WA_DeleteOnClose); - error_message->showMessage(tr("This Strawberry binary was built for %1 CPU, but you are running on an %2 CPU. Strawberry currently have limited macOS support, and running this binary on the current CPU is unsupported. If you want to use Strawberry on the current CPU, you should build Strawberry from source. For instructions see.: https://wiki.strawberrymusicplayer.org/wiki/Compile").arg(QSysInfo::buildCpuArchitecture()).arg(QSysInfo::currentCpuArchitecture())); + error_message->showMessage(tr("It is detected that Strawberry is running under Rosetta. Strawberry currently have limited macOS support, and running Strawberry under Rosetta is unsupported and known to have issues. If you want to use Strawberry on the current CPU, you should build Strawberry from source. For instructions see.: https://wiki.strawberrymusicplayer.org/wiki/Compile")); } #endif diff --git a/src/utilities/macosutils.h b/src/utilities/macosutils.h index 2e111cf60..1d93d3165 100644 --- a/src/utilities/macosutils.h +++ b/src/utilities/macosutils.h @@ -26,6 +26,7 @@ namespace Utilities { qint32 GetMacOsVersion(); void IncreaseFDLimit(); +bool ProcessTranslated(); } // namespace Utilities diff --git a/src/utilities/macosutils.mm b/src/utilities/macosutils.mm index 543cf88d3..36048e278 100644 --- a/src/utilities/macosutils.mm +++ b/src/utilities/macosutils.mm @@ -59,4 +59,16 @@ void IncreaseFDLimit() { } +bool ProcessTranslated() { + + int value = 0; + size_t value_size = sizeof(value); + if (sysctlbyname("sysctl.proc_translated", &value, &value_size, nullptr, 0) != 0) { + return false; + } + + return value == 1; + +} + } // namespace Utilities