Revision: 29841
          http://sourceforge.net/p/bibdesk/svn/29841
Author:   hofman
Date:     2025-11-18 16:50:22 +0000 (Tue, 18 Nov 2025)
Log Message:
-----------
avoid deprecated coding initializers

Modified Paths:
--------------
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageCache.m

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageCache.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageCache.m  2025-11-18 
15:54:45 UTC (rev 29840)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageCache.m  2025-11-18 
16:50:22 UTC (rev 29841)
@@ -43,6 +43,26 @@
 static CGImageRef FVCreateCGImageWithData(NSData *data);
 static NSData *FVCreateDataWithCGImage(CGImageRef image);
 
+#if !defined(MAC_OS_X_VERSION_10_12) || MAC_OS_X_VERSION_MAX_ALLOWED < 
MAC_OS_X_VERSION_10_12
+
+@interface NSKeyedArchiver (FVSerriaExtensions)
+- (NSData *)encodedData;
+@end
+
+#endif
+
+#if !defined(MAC_OS_X_VERSION_10_13) || MAC_OS_X_VERSION_MAX_ALLOWED < 
MAC_OS_X_VERSION_10_13
+
+@interface NSKeyedArchiver (FVHighSerriaExtensions)
+- (instancetype)initRequiringSecureCoding:(BOOL)requiresSecureCoding;
+@end
+
+@interface NSKeyedUnrchiver (FVHighSerriaExtensions)
+- (nullable instancetype)initForReadingFromData:(NSData *)data error:(NSError 
**)error;
+@end
+
+#endif
+
 @implementation FVCGImageCache
 
 static FVCacheFile *_bigImageCache = nil;
@@ -147,7 +167,13 @@
         toReturn = CGImageSourceCreateImageAtIndex(imsrc, 0, NULL);
     if (imsrc) CFRelease(imsrc);
 #else
-    NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] 
initForReadingWithData:data];
+    NSKeyedUnarchiver *unarchiver = nil;
+#if !defined(MAC_OS_X_VERSION_10_13) || MAC_OS_X_VERSION_MIN_REQUIRED < 
MAC_OS_X_VERSION_10_13
+    if ([NSKeyedUnarchiver 
respondsToSelector:@selector(initForReadingFromData:error:)] == NO)
+        unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
+    else
+#endif
+    unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:data 
error:NULL];
     // only retained by unarchiver
     FVCGImageDescription *imageDescription = [unarchiver decodeObject];
     [unarchiver finishDecoding];
@@ -169,15 +195,25 @@
 #else
     FVCGImageDescription *imageDescription = [[FVCGImageDescription alloc] 
initWithImage:image];
     
-    // do not call setLength:, even before writing the archive!
-    size_t approximateLength = CGImageGetBytesPerRow(image) * 
CGImageGetHeight(image) + 20 * sizeof(size_t);
-    NSMutableData *mdata = [[NSMutableData alloc] 
initWithCapacity:approximateLength];
+    NSKeyedArchiver *archiver = nil;
     
-    NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] 
initForWritingWithMutableData:mdata];
-    [archiver encodeObject:imageDescription];
-    [archiver finishEncoding];
-    
-    data = mdata;
-#endif    
+#if !defined(MAC_OS_X_VERSION_10_13) || MAC_OS_X_VERSION_MIN_REQUIRED < 
MAC_OS_X_VERSION_10_13
+    if ([NSKeyedArchiver 
respondsToSelector:@selector(initRequiringSecureCoding:)] == NO) {
+        // do not call setLength:, even before writing the archive!
+        size_t approximateLength = CGImageGetBytesPerRow(image) * 
CGImageGetHeight(image) + 20 * sizeof(size_t);
+        NSMutableData *mdata = [[NSMutableData alloc] 
initWithCapacity:approximateLength];
+        archiver = [[NSKeyedArchiver alloc] 
initForWritingWithMutableData:mdata];
+        [archiver encodeObject:imageDescription];
+        [archiver finishEncoding];
+        data = mdata;
+    } else
+#endif
+    {
+        archiver = [[NSKeyedArchiver alloc] initRequiringSecureCoding:NO];
+        [archiver encodeObject:imageDescription];
+        [archiver finishEncoding];
+        data = [archiver encodedData];
+    }
+#endif
     return data;
 }

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