Skip to content

Commit 9611ef5

Browse files
sunshinecoj6t
authored andcommitted
gitk: fix MacOS 10.14 "Mojave" crash on launch
On MacOS, a "wish" application started from the terminal opens in the background, thus doesn't match user expectation that a newly-launched application ought to be placed in the foreground. To address this shortcoming, both gitk and git-gui use Apple Events to send a message to "System Events" instructing it to foreground the "wish" application by PID. Unfortunately, MacOS 10.14 tightens restrictions on Apple Events, requiring explicit granting of permission to control applications in this fashion, and apparently such granting for "Automation" is not allowed at all[1]. As a consequence gitk crashes outright at launch time with a "Not authorized to send Apple events to System Events" error, thus is entirely unusable on "Mojave". In contrast, git-gui does not crash since it deliberately[2] catches and ignores Apple Events errors. This does mean that git-gui will not automatically become the foreground application on "Mojave", which is a minor inconvenience but far better than crashing outright as gitk does. Update gitk to catch and ignore Apple Events errors, mirroring git-gui's behavior, to avoid this crash. (Finding and implementing an alternate approach to foregrounding the "wish" application on "Mojave" may be desirable but is outside the scope of this crash fix.) [1]: https://lore.kernel.org/git/[email protected]/ [2]: https://lore.kernel.org/git/CABNJ2G+h3zh+=wLA0KHjUn8TsfhqUK1Kn-1_=6hnXVRJUPhuuA@mail.gmail.com/ Reported-by: Evgeny Cherpak <[email protected]> Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Johannes Sixt <[email protected]>
1 parent ac8fec7 commit 9611ef5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

gitk

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12460,11 +12460,13 @@ namespace import ::msgcat::mc
1246012460
1246112461
# on OSX bring the current Wish process window to front
1246212462
if {[tk windowingsystem] eq "aqua"} {
12463-
safe_exec [list osascript -e [format {
12464-
tell application "System Events"
12465-
set frontmost of processes whose unix id is %d to true
12466-
end tell
12467-
} [pid] ]]
12463+
catch {
12464+
safe_exec [list osascript -e [format {
12465+
tell application "System Events"
12466+
set frontmost of processes whose unix id is %d to true
12467+
end tell
12468+
} [pid] ]]
12469+
}
1246812470
}
1246912471
1247012472
# Unset GIT_TRACE var if set

0 commit comments

Comments
 (0)