From cf9f7ef508cb96718bcd959879b5e3c4a299f9d7 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 26 Sep 2018 13:18:29 +0300 Subject: [PATCH] Fix several bugs for macOS 10.14. --- Telegram/Patches/qtbase_5_6_2.diff | 18 +++++++++++++++--- .../SourceFiles/platform/mac/specific_mac_p.mm | 7 ++++++- Telegram/Telegram.plist | 2 ++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Telegram/Patches/qtbase_5_6_2.diff b/Telegram/Patches/qtbase_5_6_2.diff index e6906ff1a3..8457cd4201 100644 --- a/Telegram/Patches/qtbase_5_6_2.diff +++ b/Telegram/Patches/qtbase_5_6_2.diff @@ -253,7 +253,7 @@ index 41834b21ae..8cdf4ab145 100644 setError(QAbstractSocket::NetworkError, AddressNotAvailableErrorString); socketState = QAbstractSocket::UnconnectedState; diff --git a/src/platformsupport/dbustray/qdbustrayicon.cpp b/src/platformsupport/dbustray/qdbustrayicon.cpp -index 4d6e707..9bdb0be 100644 +index 4d6e70720d..9bdb0beb67 100644 --- a/src/platformsupport/dbustray/qdbustrayicon.cpp +++ b/src/platformsupport/dbustray/qdbustrayicon.cpp @@ -58,9 +58,18 @@ QT_BEGIN_NAMESPACE @@ -667,7 +667,7 @@ index c2d206fb45..9b9739862d 100644 } return ret; diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm -index 8152c57ffd..5ddd7b353d 100644 +index 8152c57ffd..87ba2f3f72 100644 --- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm +++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm @@ -94,6 +94,8 @@ QT_USE_NAMESPACE @@ -783,7 +783,19 @@ index 8152c57ffd..5ddd7b353d 100644 systray = sys; imageCell = [[QNSImageView alloc] initWithParent:self]; [item setView: imageCell]; -@@ -482,6 +513,10 @@ QT_END_NAMESPACE +@@ -448,6 +479,11 @@ QT_END_NAMESPACE + -(void)dealloc { + [[NSStatusBar systemStatusBar] removeStatusItem:item]; + [[NSNotificationCenter defaultCenter] removeObserver:imageCell]; ++ ++ // Patch: Fix crash in macOS 10.14. ++ // Somehow item and imageCell are retained and attempt to be drawn if left in view. ++ [item setView: nil]; ++ + [imageCell release]; + [item release]; + [super dealloc]; +@@ -482,6 +518,10 @@ QT_END_NAMESPACE selector:@selector(menuTrackingDone:) name:NSMenuDidEndTrackingNotification object:m]; diff --git a/Telegram/SourceFiles/platform/mac/specific_mac_p.mm b/Telegram/SourceFiles/platform/mac/specific_mac_p.mm index e3b5659255..ba43a3e6c0 100644 --- a/Telegram/SourceFiles/platform/mac/specific_mac_p.mm +++ b/Telegram/SourceFiles/platform/mac/specific_mac_p.mm @@ -121,7 +121,12 @@ ApplicationDelegate *_sharedDelegate = nil; }); #ifndef OS_MAC_STORE if ([SPMediaKeyTap usesGlobalMediaKeyTap]) { - _keyTap = [[SPMediaKeyTap alloc] initWithDelegate:self]; + if (QSysInfo::macVersion() < Q_MV_OSX(10, 14)) { + _keyTap = [[SPMediaKeyTap alloc] initWithDelegate:self]; + } else { + // In macOS Mojave it requires accessibility features. + LOG(("Media key monitoring disabled in Mojave.")); + } } else { LOG(("Media key monitoring disabled")); } diff --git a/Telegram/Telegram.plist b/Telegram/Telegram.plist index 0f26e8046a..47bdf4d774 100644 --- a/Telegram/Telegram.plist +++ b/Telegram/Telegram.plist @@ -37,6 +37,8 @@ $(MACOSX_DEPLOYMENT_TARGET) NOTE + NSMicrophoneUsageDescription + We need access to your microphone so that you can record voice messages and make calls. NSPrincipalClass NSApplication NSSupportsAutomaticGraphicsSwitching