ecore_cocoa_cnp: clear the clipboard only if writable
authorJean Guyomarc'h <jean.guyomarch@openwide.fr>
Thu, 15 Oct 2015 08:38:53 +0000 (10:38 +0200)
committerCedric BAIL <cedric@osg.samsung.com>
Tue, 1 Dec 2015 20:15:32 +0000 (12:15 -0800)
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
src/lib/ecore_cocoa/ecore_cocoa_cnp.m

index f94dfe9..605bfa9 100644 (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
@@ -55,6 +51,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];
      }