Commit e1bc8209 authored by Daniel Murphy's avatar Daniel Murphy
Browse files

Set QT layer for Error Reporter on BigSur

Put this workaround in common function in mantidqt.utils
parent abeeb1e0
......@@ -15,6 +15,7 @@ from functools import partial
from mantid.api import FrameworkManagerImpl
from mantid.kernel import ConfigService, UsageService, version_str as mantid_version_str
from mantidqt.utils.qt import plugins
import mantidqt.utils.qt as qtutils
# Find Qt plugins for development builds on some platforms
plugins.setup_library_paths()
......@@ -87,17 +88,7 @@ def initialize():
import asyncio
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
if sys.platform == 'darwin':
# Force layer-backing on macOS >= Big Sur (11)
# or the application hangs
# A fix inside Qt is yet to be released:
# https://codereview.qt-project.org/gitweb?p=qt/qtbase.git;a=commitdiff;h=c5d904639dbd690a36306e2b455610029704d821
# A complication with Big Sur numbering means we check for 10.16 and 11:
# https://eclecticlight.co/2020/08/13/macos-version-numbering-isnt-so-simple/
from distutils.version import LooseVersion
import platform
mac_vers = LooseVersion(platform.mac_ver()[0])
if mac_vers >= '11' or mac_vers == '10.16':
os.environ['QT_MAC_WANTS_LAYER'] = '1'
qtutils.force_layer_backing_BigSur()
app = qapplication()
......
......@@ -7,7 +7,6 @@
import argparse
import importlib
import sys
import os
import mantid
from qtpy import QT_VERSION
......@@ -15,6 +14,7 @@ from qtpy.QtCore import QCoreApplication
from mantidqt.dialogs.errorreports.presenter import ErrorReporterPresenter
from mantidqt.dialogs.errorreports.report import CrashReportPage
import mantidqt.utils.qt as qtutils
def main() -> int:
......@@ -33,18 +33,7 @@ def main() -> int:
importlib.import_module(f'mantidqt.dialogs.errorreports.resources_qt{QT_VERSION[0]}')
if sys.platform == 'darwin':
# Force layer-backing on macOS >= Big Sur (11)
# or the application hangs
# A fix inside Qt is yet to be released:
# https://codereview.qt-project.org/gitweb?p=qt/qtbase.git;a=commitdiff;h=c5d904639dbd690a36306e2b455610029704d821
# A complication with Big Sur numbering means we check for 10.16 and 11:
# https://eclecticlight.co/2020/08/13/macos-version-numbering-isnt-so-simple/
from distutils.version import LooseVersion
import platform
mac_vers = LooseVersion(platform.mac_ver()[0])
if mac_vers >= '11' or mac_vers == '10.16':
os.environ['QT_MAC_WANTS_LAYER'] = '1'
print('############\nDANIEL WAS HERE\n##############\n')
qtutils.force_layer_backing_BigSur()
from qtpy.QtWidgets import QApplication
app = QApplication(sys.argv)
......
......@@ -10,6 +10,7 @@
"""A selection of utility functions related to Qt functionality
"""
# stdlib modules
import os
import os.path as osp
from contextlib import contextmanager
from importlib import import_module
......@@ -210,3 +211,17 @@ def ensure_widget_is_on_screen(widget):
y = desktop_geom.bottom() - widget_geom.height()
window_pos = QPoint(x, y)
widget.move(window_pos)
def force_layer_backing_BigSur():
# Force layer-backing on macOS >= Big Sur (11)
# or the application hangs
# A fix inside Qt is yet to be released:
# https://codereview.qt-project.org/gitweb?p=qt/qtbase.git;a=commitdiff;h=c5d904639dbd690a36306e2b455610029704d821
# A complication with Big Sur numbering means we check for 10.16 and 11:
# https://eclecticlight.co/2020/08/13/macos-version-numbering-isnt-so-simple/
from distutils.version import LooseVersion
import platform
mac_vers = LooseVersion(platform.mac_ver()[0])
if mac_vers >= '11' or mac_vers == '10.16':
os.environ['QT_MAC_WANTS_LAYER'] = '1'
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment