diff --git a/ChangeLog.txt b/ChangeLog.txt index b589dabc9..8b7108f86 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -15,6 +15,7 @@ - New option. Default piece label template for new pieces. - Shortcut to quickly enable/disable Interactive tools mode. - Improve labels for V notch. +- Fix QT issue on MacOS version 11.0 "Big Sur". # Valentina 0.7.52 September 12, 2022 - Fix crash when default locale is ru. diff --git a/src/app/puzzle/main.cpp b/src/app/puzzle/main.cpp index 570b8e8c3..123d7c8e9 100644 --- a/src/app/puzzle/main.cpp +++ b/src/app/puzzle/main.cpp @@ -69,7 +69,13 @@ auto main(int argc, char *argv[]) -> int #ifndef Q_OS_MAC // supports natively InitHighDpiScaling(argc, argv); -#endif //Q_OS_MAC +#endif //ndef Q_OS_MAC + +#ifdef Q_OS_MAC +#if MACOS_LAYER_BACKING_AFFECTED + MacosEnableLayerBacking(); +#endif // MACOS_LAYER_BACKING_AFFECTED +#endif // Q_OS_MAC #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) XERCES_CPP_NAMESPACE::XMLPlatformUtils::Initialize(); diff --git a/src/app/tape/main.cpp b/src/app/tape/main.cpp index 564ebf79b..8a1a6e5a6 100644 --- a/src/app/tape/main.cpp +++ b/src/app/tape/main.cpp @@ -75,6 +75,12 @@ auto main(int argc, char *argv[]) -> int InitHighDpiScaling(argc, argv); #endif //Q_OS_MAC +#ifdef Q_OS_MAC +#if MACOS_LAYER_BACKING_AFFECTED + MacosEnableLayerBacking(); +#endif // MACOS_LAYER_BACKING_AFFECTED +#endif // Q_OS_MAC + MApplication app(argc, argv); app.InitOptions(); diff --git a/src/app/valentina/main.cpp b/src/app/valentina/main.cpp index 89aa3cd35..df503cc78 100644 --- a/src/app/valentina/main.cpp +++ b/src/app/valentina/main.cpp @@ -81,6 +81,12 @@ auto main(int argc, char *argv[]) -> int InitHighDpiScaling(argc, argv); #endif //Q_OS_MAC +#ifdef Q_OS_MAC +#if MACOS_LAYER_BACKING_AFFECTED + MacosEnableLayerBacking(); +#endif // MACOS_LAYER_BACKING_AFFECTED +#endif // Q_OS_MAC + #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) XERCES_CPP_NAMESPACE::XMLPlatformUtils::Initialize(); diff --git a/src/libs/vmisc/def.cpp b/src/libs/vmisc/def.cpp index ef37fe790..bc9b17ef4 100644 --- a/src/libs/vmisc/def.cpp +++ b/src/libs/vmisc/def.cpp @@ -304,6 +304,22 @@ void InitHighDpiScaling(int argc, char *argv[]) } } +//--------------------------------------------------------------------------------------------------------------------- +#ifdef Q_OS_MAC +#if MACOS_LAYER_BACKING_AFFECTED +void MacosEnableLayerBacking() +{ + QOperatingSystemVersion osVer = QOperatingSystemVersion::current(); + const int majorVer = osVer.majorVersion(); + const int minorVer = osVer.minorVersion(); + if (((majorVer == 10 && minorVer >= 16) || majorVer >= 11) && qEnvironmentVariableIsEmpty("QT_MAC_WANTS_LAYER")) + { + qputenv("QT_MAC_WANTS_LAYER", "1"); + } +} +#endif // MACOS_LAYER_BACKING_AFFECTED +#endif // Q_OS_MAC + Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTMark, (QLatin1String("tMark"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strVMark, (QLatin1String("vMark"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strVMark2, (QLatin1String("vMark2"))) // NOLINT diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index a6e28a5d9..f60e21ac1 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -370,6 +370,35 @@ if (!(cond)) \ bool IsOptionSet(int argc, char *argv[], const char *option); void InitHighDpiScaling(int argc, char *argv[]); +#ifdef Q_OS_MAC +// Fix QT issue on MacOS version 11.0 "Big Sur" +// https://bugreports.qt.io/browse/QTBUG-87014 +// Enables layer backing for Big Sur +// Prevents 100% CPU & RAM utilization +// +// The fix at +// +// https://codereview.qt-project.org/c/qt/qtbase/+/322228/3/src/plugins/platforms/cocoa/qnsview_drawing.mm +// +// enables layer backing if we're running on Big Sur OR we're running on +// Catalina AND we were built with the Catalina SDK. Enable layer backing +// here by setting QT_MAC_WANTS_LAYER=1, but only if we're running on Big +// Sur and our version of Qt doesn't have a fix for QTBUG-87014. + +// We'll assume that it will be fixed in 5.12.11, 5.15.3, and 6.0.1. +// Feel free to add other versions if needed. +#define MACOS_LAYER_BACKING_AFFECTED \ +(QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) && QT_VERSION < QT_VERSION_CHECK(5, 12, 11) \ + || (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) && QT_VERSION < QT_VERSION_CHECK(5, 15, 3)) \ + || (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 1)) \ + ) + +#if MACOS_LAYER_BACKING_AFFECTED +#include +void MacosEnableLayerBacking(); +#endif // MACOS_LAYER_BACKING_AFFECTED +#endif // Q_OS_MAC + // Don't forget to syncronize with XSD schema. const int userMaterialPlaceholdersQuantity = 20;