Skip to content

Commit 1adb42b

Browse files
committed
Fix MacVim crashing on 10.9
This fixes MacVim to work again on OSX 10.9. It was previously crashing on launch for last few versions. titlebarAppearsTransparent call: This API was added in 10.10, and previously MacVim wasn't properly guarding it with the proper OS version check, causing it to crash under 10.9 (which is the lowest currently supported macOS version). CGContext call: The new stateful renderer is using a newer API to retrieve the CGContext from the NS wrapper, but that was also only added in 10.10. When compiling against older versions, just use the older, now-deprecated API "graphicsPort" instead. It still works. Also, change the version check for `safeAreaInsets` for non-native full screen to use `@available` as well instead of checking for selector. This is more consistent with how other code works and fixes a compiler warning about not checking for OS version. Fix #1212
1 parent 8d23829 commit 1adb42b

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/MacVim/MMCoreTextView.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,12 @@ - (void)setNeedsDisplayFromRow:(int)row column:(int)col toRow:(int)row2
734734
- (void)drawRect:(NSRect)rect
735735
{
736736
NSGraphicsContext *context = [NSGraphicsContext currentContext];
737+
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10
737738
CGContextRef ctx = context.CGContext;
739+
#else
740+
CGContextRef ctx = [context graphicsPort];
741+
#endif
742+
738743
[context setShouldAntialias:antialias];
739744
{
740745
CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);

src/MacVim/MMFullScreenWindow.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ - (NSEdgeInsets) viewOffset {
382382

383383
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_12_0)
384384
// Account for newer MacBook Pro's which have a notch, which can be queried using the safe area API.
385-
if ([NSScreen instancesRespondToSelector:@selector(safeAreaInsets)]) {
385+
if (@available(macos 12.0, *)) {
386386
const int safeAreaBehavior = [[NSUserDefaults standardUserDefaults]
387387
integerForKey:MMNonNativeFullScreenSafeAreaBehaviorKey];
388388

src/MacVim/MMWindowController.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,12 @@ - (void)refreshApperanceMode
571571
// has selected as a preference.
572572

573573
// Transparent title bar setting
574-
decoratedWindow.titlebarAppearsTransparent = [[NSUserDefaults standardUserDefaults]
575-
boolForKey:MMTitlebarAppearsTransparentKey];
574+
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10
575+
if (@available(macos 10.10, *)) {
576+
decoratedWindow.titlebarAppearsTransparent = [[NSUserDefaults standardUserDefaults]
577+
boolForKey:MMTitlebarAppearsTransparentKey];
578+
}
579+
#endif
576580

577581
// No title bar setting
578582
if ([[NSUserDefaults standardUserDefaults]

0 commit comments

Comments
 (0)