Skip to content

Commit

Permalink
macOS: Workaround for Qt UI not working on Big Sur
Browse files Browse the repository at this point in the history
It turns out if we set the env var QT_MAC_WANTS_LAYER=1, then Qt>=5.13.2
will work correctly on macOS Big Sur.

See: https://bugreports.qt.io/browse/QTBUG-87014
Related: spesmilo#6461
  • Loading branch information
cculianu authored and EchterAgo committed Mar 11, 2021
1 parent 87a296d commit 956acd5
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion electroncash_gui/qt/__init__.py
Expand Up @@ -24,7 +24,14 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import gc, os, platform, shutil, signal, sys, traceback, weakref
import gc
import os
import platform
import shutil
import signal
import sys
import traceback
import weakref

try:
import PyQt5
Expand Down Expand Up @@ -277,6 +284,21 @@ def undo_hack():

callables.append(undo_hack)

# macOS Big Sur workaround for Qt>=5.13.2 sometimes not working at all
# See: https://bugreports.qt.io/browse/QTBUG-87014
# See also: https://stackoverflow.com/questions/64818879/is-there-any-solution-regarding-to-pyqt-library-doesnt-work-in-mac-os-big-sur
if sys.platform in ('darwin', ):
try:
release_tuple = version.normalize_version(platform.uname().release)
self.print_error("Darwin kernel version:", '.'.join([str(x) for x in release_tuple]))
except Exception as e:
release_tuple = (0, 0, 0)
self.print_error("Error parsing Darwin kernel version:", repr(e))
if release_tuple >= (20, 0, 0) and self.qt_version() > (5, 13, 1):
# Setting this env var causes Qt to use some other macOS API that always works on Big Sur
os.environ['QT_MAC_WANTS_LAYER'] = '1'
self.print_error(f"macOS Big Sur Qt workaround applied")

def setup_layout_direction():
"""Sets the app layout direction depending on language. To be called
after self.app is created successfully. Note this *MUST* be called
Expand Down

0 comments on commit 956acd5

Please sign in to comment.