Revision: 13977
          http://sourceforge.net/p/skim-app/code/13977
Author:   hofman
Date:     2023-12-24 17:27:43 +0000 (Sun, 24 Dec 2023)
Log Message:
-----------
create placeholder bookmark instance in alloc using dispatch_once

Modified Paths:
--------------
    trunk/SKBookmark.m

Modified: trunk/SKBookmark.m
===================================================================
--- trunk/SKBookmark.m  2023-12-24 16:33:59 UTC (rev 13976)
+++ trunk/SKBookmark.m  2023-12-24 17:27:43 UTC (rev 13977)
@@ -94,17 +94,24 @@
 @synthesize parent;
 @dynamic properties, bookmarkType, label, icon, alternateIcon, fileURL, 
fileURLToOpen, fileDescription, toolTip, pageIndex, pageNumber, hasSetup, tabs, 
containingBookmarks, children, countOfChildren, scriptingParent, 
entireContents, bookmarks, expanded, skimURL;
 
-static SKPlaceholderBookmark *defaultPlaceholderBookmark = nil;
 static Class SKBookmarkClass = Nil;
 
 + (void)initialize {
     SKINITIALIZE;
     SKBookmarkClass = self;
-    defaultPlaceholderBookmark = [SKPlaceholderBookmark alloc];
 }
 
 + (instancetype)allocWithZone:(NSZone *)aZone {
-    return SKBookmarkClass == self ? defaultPlaceholderBookmark : [super 
allocWithZone:aZone];
+    if (SKBookmarkClass == self) {
+        static SKPlaceholderBookmark *placeholderBookmark = nil;
+        dispatch_once_t onceToken = 0;
+        dispatch_once(onceToken, ^{
+            placeholderBookmark = [SKPlaceholderBookmark alloc];
+        });
+        return placeholderBookmark;
+    } else {
+        return [super allocWithZone:aZone];
+    }
 }
 
 + (instancetype)bookmarkWithURL:(NSURL *)aURL pageIndex:(NSUInteger)aPageIndex 
label:(NSString *)aLabel {

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