Skip to content
Permalink
Browse files

Merge PR #3603: GlobalShortcutMac: fix segmentation fault in setEnabl…

…ed()
  • Loading branch information...
davidebeatrici committed May 25, 2019
2 parents cbbc342 + d7353b7 commit 4e8391397409122c860797042a39d95257407ed9
Showing with 17 additions and 5 deletions.
  1. +17 −5 src/mumble/GlobalShortcut_macx.mm
@@ -120,7 +120,10 @@
return suppress ? NULL : event;
}

GlobalShortcutMac::GlobalShortcutMac() : modmask(static_cast<CGEventFlags>(0)) {
GlobalShortcutMac::GlobalShortcutMac()
: loop(Q_NULLPTR)
, port(Q_NULLPTR)
, modmask(static_cast<CGEventFlags>(0)) {
#ifndef QT_NO_DEBUG
qWarning("GlobalShortcutMac: Debug build detected. Disabling shortcut engine.");
return;
@@ -186,9 +189,11 @@
#ifndef QT_NO_DEBUG
return;
#endif
CFRunLoopStop(loop);
loop = NULL;
wait();
if (loop) {
CFRunLoopStop(loop);
loop = Q_NULLPTR;
wait();
}
}

void GlobalShortcutMac::dumpEventTaps() {
@@ -445,10 +450,17 @@
}

void GlobalShortcutMac::setEnabled(bool b) {
CGEventTapEnable(port, b);
// Since Mojave, passing NULL to CGEventTapEnable() segfaults.
if (port) {
CGEventTapEnable(port, b);
}
}

bool GlobalShortcutMac::enabled() {
if (!port) {
return false;
}

return CGEventTapIsEnabled(port);
}

0 comments on commit 4e83913

Please sign in to comment.
You can’t perform that action at this time.