Skip to content

Commit d595a19

Browse files
committed
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Problem: Mac: NSStringPboardType is deprecated. Solution: Use NSPasteboardTypeString. (Akshay Hegde, closes #3022)
1 parent 491ac28 commit d595a19

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/os_macosx.m

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,13 @@
6363
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
6464

6565
NSPasteboard *pb = [NSPasteboard generalPasteboard];
66+
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
67+
NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType,
68+
NSPasteboardTypeString, nil];
69+
#else
6670
NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType,
6771
NSStringPboardType, nil];
72+
#endif
6873
NSString *bestType = [pb availableTypeFromArray:supportedTypes];
6974
if (!bestType) goto releasepool;
7075

@@ -76,7 +81,7 @@
7681
/* This type should consist of an array with two objects:
7782
* 1. motion type (NSNumber)
7883
* 2. text (NSString)
79-
* If this is not the case we fall back on using NSStringPboardType.
84+
* If this is not the case we fall back on using NSPasteboardTypeString.
8085
*/
8186
id plist = [pb propertyListForType:VimPboardType];
8287
if ([plist isKindOfClass:[NSArray class]] && [plist count] == 2)
@@ -92,10 +97,15 @@
9297

9398
if (!string)
9499
{
95-
/* Use NSStringPboardType. The motion type is detected automatically.
100+
/* Use NSPasteboardTypeString. The motion type is detected automatically.
96101
*/
102+
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
103+
NSMutableString *mstring =
104+
[[pb stringForType:NSPasteboardTypeString] mutableCopy];
105+
#else
97106
NSMutableString *mstring =
98107
[[pb stringForType:NSStringPboardType] mutableCopy];
108+
#endif
99109
if (!mstring) goto releasepool;
100110

101111
/* Replace unrecognized end-of-line sequences with \x0a (line feed). */
@@ -178,15 +188,24 @@
178188

179189
/* See clip_mch_request_selection() for info on pasteboard types. */
180190
NSPasteboard *pb = [NSPasteboard generalPasteboard];
191+
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
192+
NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType,
193+
NSPasteboardTypeString, nil];
194+
#else
181195
NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType,
182196
NSStringPboardType, nil];
197+
#endif
183198
[pb declareTypes:supportedTypes owner:nil];
184199

185200
NSNumber *motion = [NSNumber numberWithInt:motion_type];
186201
NSArray *plist = [NSArray arrayWithObjects:motion, string, nil];
187202
[pb setPropertyList:plist forType:VimPboardType];
188203

204+
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
205+
[pb setString:string forType:NSPasteboardTypeString];
206+
#else
189207
[pb setString:string forType:NSStringPboardType];
208+
#endif
190209

191210
[string release];
192211
}

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
63,
764766
/**/
765767
62,
766768
/**/

0 commit comments

Comments
 (0)