Revision: 27264
          http://sourceforge.net/p/bibdesk/svn/27264
Author:   hofman
Date:     2022-03-04 15:09:29 +0000 (Fri, 04 Mar 2022)
Log Message:
-----------
make sure promised pboard data is registered before writing it to pboard to 
avoid race conditions

Modified Paths:
--------------
    trunk/bibdesk/BDSKItemPasteboardHelper.m

Modified: trunk/bibdesk/BDSKItemPasteboardHelper.m
===================================================================
--- trunk/bibdesk/BDSKItemPasteboardHelper.m    2022-03-04 07:30:16 UTC (rev 
27263)
+++ trunk/bibdesk/BDSKItemPasteboardHelper.m    2022-03-04 15:09:29 UTC (rev 
27264)
@@ -98,26 +98,28 @@
     
     NSMutableArray *types = [NSMutableArray 
arrayWithObjects:BDSKPasteboardTypePublications, nil];
     
-    if (text != nil) {
+    switch (dragCopyType) {
+        case BDSKDragCopyPDF:
+            [types addObject:NSPasteboardTypePDF];
+            break;
+        case BDSKDragCopyRTF:
+            [types addObject:NSPasteboardTypeRTF];
+            break;
+        case BDSKDragCopyLaTeX:
+        case BDSKDragCopyLTB:
+            [types addObject:NSPasteboardTypeString];
+            break;
+        default:
+            break;
+    }
+    
+    [self setPromisedTypes:types items:items dragCopyType:dragCopyType 
forPasteboard:pboard];
+    
+    if (text != nil)
         [pboard writeObjects:[NSArray arrayWithObjects:text, nil]];
-    } else if (dragCopyType == BDSKDragCopyURL) {
+    else if (dragCopyType == BDSKDragCopyURL)
         [pboard writeURLs:[items valueForKey:@"bdskURL"] names:[items 
valueForKey:@"citeKey"]];
-    } else {
-        switch (dragCopyType) {
-            case BDSKDragCopyPDF:
-                [types addObject:NSPasteboardTypePDF];
-                break;
-            case BDSKDragCopyRTF:
-                [types addObject:NSPasteboardTypeRTF];
-                break;
-            case BDSKDragCopyLaTeX:
-            case BDSKDragCopyLTB:
-                [types addObject:NSPasteboardTypeString];
-                break;
-            default:
-                break;
-        }
-    }
+    
     if ([[pboard pasteboardItems] count] > 0) {
         [[[pboard pasteboardItems] firstObject] setDataProvider:self 
forTypes:types];
     } else {
@@ -125,8 +127,6 @@
         [item setDataProvider:self forTypes:types];
         [pboard writeObjects:[NSArray arrayWithObjects:item, nil]];
     }
-    
-    [self setPromisedTypes:types items:items dragCopyType:dragCopyType 
forPasteboard:pboard];
 }
 
 #pragma mark NSPasteboardItemDataProvider protocol methods

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to