Revision: 13816
          http://sourceforge.net/p/skim-app/code/13816
Author:   hofman
Date:     2023-11-30 15:33:21 +0000 (Thu, 30 Nov 2023)
Log Message:
-----------
use associated object to set isSkimNote flag

Modified Paths:
--------------
    trunk/SkimNotes/PDFAnnotation_SKNExtensions.m

Modified: trunk/SkimNotes/PDFAnnotation_SKNExtensions.m
===================================================================
--- trunk/SkimNotes/PDFAnnotation_SKNExtensions.m       2023-11-30 10:11:22 UTC 
(rev 13815)
+++ trunk/SkimNotes/PDFAnnotation_SKNExtensions.m       2023-11-30 15:33:21 UTC 
(rev 13816)
@@ -205,6 +205,8 @@
 
 @implementation PDFAnnotation (SKNExtensions)
 
+#if !defined(PDFKIT_PLATFORM_IOS) && MAC_OS_X_VERSION_MIN_REQUIRED < 
MAC_OS_X_VERSION_10_6
+
 static NSHashTable *SkimNotes = nil;
 
 static void (*original_dealloc)(id, SEL) = NULL;
@@ -218,15 +220,17 @@
 
 + (void)load {
     NSAutoreleasePool *pool = [NSAutoreleasePool new];
-#if !defined(PDFKIT_PLATFORM_IOS) && (!defined(MAC_OS_X_VERSION_10_8) || 
MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8)
     SkimNotes = [[NSHashTable alloc] 
initWithOptions:NSHashTableZeroingWeakMemory | 
NSHashTableObjectPointerPersonality capacity:0];
-#else
-    SkimNotes = [[NSHashTable alloc] initWithOptions:NSHashTableWeakMemory | 
NSHashTableObjectPointerPersonality capacity:0];
-#endif
     original_dealloc = 
(void(*)(id,SEL))method_setImplementation(class_getInstanceMethod(self, 
@selector(dealloc)), (IMP)replacement_dealloc);
     [pool release];
 }
 
+#else
+
+char SKNIsSkimNoteKey;
+
+#endif
+
 #if !defined(PDFKIT_PLATFORM_IOS)
 static inline Class SKNAnnotationClassForType(NSString *type) {
 #pragma clang diagnostic push
@@ -857,7 +861,11 @@
 - (BOOL)isSkimNote {
     BOOL isSkimNote;
     @synchronized([PDFAnnotation self]) {
+#if !defined(PDFKIT_PLATFORM_IOS) && MAC_OS_X_VERSION_MIN_REQUIRED < 
MAC_OS_X_VERSION_10_6
         isSkimNote = [SkimNotes containsObject:self];
+#else
+        isSkimNote = [objc_getAssociatedObject(self, &SKNIsSkimNoteKey) 
boolValue];
+#endif
     }
     return isSkimNote;
 }
@@ -864,8 +872,12 @@
 
 - (void)setSkimNote:(BOOL)flag {
     @synchronized([PDFAnnotation self]) {
+#if !defined(PDFKIT_PLATFORM_IOS) && MAC_OS_X_VERSION_MIN_REQUIRED < 
MAC_OS_X_VERSION_10_6
         if (flag) [SkimNotes addObject:self];
         else [SkimNotes removeObject:self];
+#else
+        objc_setAssociatedObject(self, &SKNIsSkimNoteKey, flag ? [NSNumber 
numberWithBool:YES] : nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+#endif
     }
 }
 

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



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to