Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
#3213: Fix crash caused by c37bea8.
  • Loading branch information
stuconnolly committed Oct 10, 2018
1 parent 582885a commit 102f6ef
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Source/SPAlertSheets.m
Expand Up @@ -30,6 +30,7 @@

#import "SPAlertSheets.h"
#import "SPMainThreadTrampoline.h"
#import "SPFunctions.h"

@implementation SPAlertSheets

Expand Down Expand Up @@ -207,7 +208,7 @@ void SPBeginAlertSheet(
void *contextInfo,
NSString *msg)
{
dispatch_sync(dispatch_get_main_queue(), ^{
void (^alertBlock)(void) = ^{
// Set up an NSAlert with the supplied details
NSAlert *alert = [[[NSAlert alloc] init] autorelease];

Expand Down Expand Up @@ -236,5 +237,12 @@ void SPBeginAlertSheet(

// Ensure the alerting window is frontmost
[docWindow makeKeyWindow];
});
};

if (dispatch_get_current_queue() == dispatch_get_main_queue()) {
alertBlock();
}
else {
dispatch_sync(dispatch_get_main_queue(), alertBlock);
}
}

2 comments on commit 102f6ef

@dmoagx
Copy link
Member

@dmoagx dmoagx commented on 102f6ef Oct 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use the SPMainQSync function?

@stuconnolly
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I was being lazy. Adding a reference to SPFunctions broke the tunnel assistant build, which I've just realised is because I forgot to include it in the sources to compile. Will get it updated.

Please sign in to comment.