Updated accessibility check logic to fix Mojave crash

This commit is contained in:
Alex Kong 2018-11-23 00:11:36 -05:00 committed by John Maguire
parent 2d07ea716a
commit 0b54e1ff0b

View File

@ -24,6 +24,7 @@
#include <AppKit/NSWorkspace.h> #include <AppKit/NSWorkspace.h>
#include <Foundation/NSString.h> #include <Foundation/NSString.h>
#include <IOKit/hidsystem/ev_keymap.h> #include <IOKit/hidsystem/ev_keymap.h>
#include <ApplicationServices/ApplicationServices.h>
#include <QAction> #include <QAction>
#include <QList> #include <QList>
@ -128,7 +129,14 @@ bool MacGlobalShortcutBackend::KeyPressed(const QKeySequence& sequence) {
} }
bool MacGlobalShortcutBackend::IsAccessibilityEnabled() const { bool MacGlobalShortcutBackend::IsAccessibilityEnabled() const {
return AXAPIEnabled(); bool accessibilityEnabled;
try{
accessibilityEnabled = AXAPIEnabled();
}catch(...){
NSDictionary *options = @{(id)kAXTrustedCheckOptionPrompt: @YES};
accessibilityEnabled = AXIsProcessTrustedWithOptions((CFDictionaryRef)options);
}
return accessibilityEnabled;
} }
void MacGlobalShortcutBackend::ShowAccessibilityDialog() { void MacGlobalShortcutBackend::ShowAccessibilityDialog() {