ecore_cocoa_cnp: clear the clipboard only if writable

This commit is contained in:
Jean Guyomarc'h 2015-10-15 10:38:53 +02:00 committed by Nicolas Aguirre
parent 9901d392ea
commit 97252e582d
1 changed files with 4 additions and 4 deletions

View File

@ -15,16 +15,12 @@ ecore_cocoa_selection_clipboard_set(const void *data,
Ecore_Cocoa_Cnp_Type type)
{
static NSMutableArray *objects = nil;
NSPasteboard *pb;
NSString *str = nil;
BOOL ok = YES;
if (!objects)
objects = [[NSMutableArray alloc] init];
pb = [NSPasteboard generalPasteboard];
[pb clearContents];
if (type & ECORE_COCOA_CNP_TYPE_STRING)
{
str = [[NSString alloc] initWithBytes: data
@ -56,6 +52,10 @@ ecore_cocoa_selection_clipboard_set(const void *data,
/* Write to pasteboard */
if ([objects count] > 0)
{
NSPasteboard *pb;
pb = [NSPasteboard generalPasteboard];
[pb clearContents];
ok = [pb writeObjects: objects];
[objects removeAllObjects];
}