From 4453856fd12a945fef5b45256b2c013a5dc6f88c Mon Sep 17 00:00:00 2001 From: skidoodle Date: Sat, 31 Jan 2026 02:10:20 +0100 Subject: [PATCH] Use NSURL and writeObjects for pasteboard files Create an NSURL from the path and write it to the general pasteboard with writeObjects:. Add nil checks for the created NSURL and remove the legacy NSFilenamesPboardType setPropertyList code. --- clipboard/darwin.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/clipboard/darwin.go b/clipboard/darwin.go index af7f71c..a41c31c 100644 --- a/clipboard/darwin.go +++ b/clipboard/darwin.go @@ -13,10 +13,13 @@ int copyFileToPasteboard(char* path) { NSString *strPath = [NSString stringWithUTF8String:path]; if (!strPath) return 0; + NSURL *url = [NSURL fileURLWithPath:strPath]; + if (!url) return 0; + NSPasteboard *pb = [NSPasteboard generalPasteboard]; [pb clearContents]; - [pb declareTypes:@[NSFilenamesPboardType] owner:nil]; - return [pb setPropertyList:@[strPath] forType:NSFilenamesPboardType] ? 1 : 0; + + return [pb writeObjects:@[url]] ? 1 : 0; } } */