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
1 changed files with 9 additions and 1 deletions

View File

@ -24,6 +24,7 @@
#include <AppKit/NSWorkspace.h>
#include <Foundation/NSString.h>
#include <IOKit/hidsystem/ev_keymap.h>
#include <ApplicationServices/ApplicationServices.h>
#include <QAction>
#include <QList>
@ -128,7 +129,14 @@ bool MacGlobalShortcutBackend::KeyPressed(const QKeySequence& sequence) {
}
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() {