1
0
mirror of https://github.com/strawberrymusicplayer/strawberry synced 2025-02-09 08:18:49 +01:00

Detect if running under Rosetta

This commit is contained in:
Jonas Kvinge 2023-03-07 23:04:00 +01:00
parent 7f76c3f2ce
commit ea8e5180ff
3 changed files with 16 additions and 2 deletions

View File

@ -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<SystemTrayIcon> 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

View File

@ -26,6 +26,7 @@ namespace Utilities {
qint32 GetMacOsVersion();
void IncreaseFDLimit();
bool ProcessTranslated();
} // namespace Utilities

View File

@ -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