summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Huddleston Sequoia <jeremyhu@apple.com>2021-01-27 15:03:46 -0800
committerJeremy Huddleston Sequoia <jeremyhu@apple.com>2021-02-02 00:46:26 +0000
commit520e7a1310ddc25b30bcaa0ea3eeaa6c4d137c8c (patch)
treef20a8fd15ea7994a1825421237dfe4d3f42d411c
parent7d0bb7ed061458698ff27856976939b261e73b23 (diff)
xquartz: Ensure that NSRunAlertPanel() is run on the main thread
Fixes: https://github.com/XQuartz/XQuartz/issues/30 Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
-rw-r--r--hw/xquartz/X11Application.m15
1 files changed, 9 insertions, 6 deletions
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 10afdf91a..a009d6415 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -1082,12 +1082,15 @@ X11ApplicationCanEnterRandR(void)
if (!XQuartzIsRootless)
QuartzShowFullscreen(FALSE);
- switch (NSRunAlertPanel(title, @"%@",
- NSLocalizedString(@"Allow",
- @""),
- NSLocalizedString(@"Cancel",
- @""),
- NSLocalizedString(@"Always Allow", @""), msg)) {
+ NSInteger __block alert_result;
+ dispatch_sync(dispatch_get_main_queue(), ^{
+ alert_result = NSRunAlertPanel(title, @"%@",
+ NSLocalizedString(@"Allow", @""),
+ NSLocalizedString(@"Cancel", @""),
+ NSLocalizedString(@"Always Allow", @""), msg);
+ });
+
+ switch (alert_result) {
case NSAlertOtherReturn:
[X11App prefs_set_boolean:@PREFS_NO_RANDR_ALERT value:YES];
[X11App prefs_synchronize];