Revision: 27787
          http://sourceforge.net/p/bibdesk/svn/27787
Author:   hofman
Date:     2022-08-10 15:50:34 +0000 (Wed, 10 Aug 2022)
Log Message:
-----------
create icon dictionaries lazily

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

Modified: trunk/bibdesk/BDSKWebIconDatabase.m
===================================================================
--- trunk/bibdesk/BDSKWebIconDatabase.m 2022-08-10 15:37:01 UTC (rev 27786)
+++ trunk/bibdesk/BDSKWebIconDatabase.m 2022-08-10 15:50:34 UTC (rev 27787)
@@ -73,8 +73,6 @@
         }
         icons = [[NSMutableDictionary alloc] initWithDictionary:[dict 
objectForKey:ICONS_KEY]];
         iconURLs = [[NSMutableDictionary alloc] initWithDictionary:[dict 
objectForKey:ICONURLS_KEY]];
-        recentIcons = [[NSMutableDictionary alloc] init];
-        cachedIcons = [[NSMutableDictionary alloc] init];
         [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(handleApplicationWillTerminate:) 
name:NSApplicationWillTerminateNotification object:nil];
     }
     return self;
@@ -103,8 +101,11 @@
     NSData *data = [icons objectForKey:iconURLString];
     if (data == nil)
         return nil;
-    if ((icon = [[[NSImage alloc] initWithData:data] autorelease]))
+    if ((icon = [[[NSImage alloc] initWithData:data] autorelease])) {
+        if (cachedIcons == nil)
+            cachedIcons = [[NSMutableDictionary alloc] init];
         [cachedIcons setObject:icon forKey:iconURLString];
+    }
     return icon;
 }
 
@@ -117,6 +118,8 @@
 - (void)setIcon:(NSImage *)icon withData:(NSData *)data 
fromURLString:(NSString *)iconURLString forURLString:(NSString *)pageURLString {
     if ([NSString isEmptyString:pageURLString])
         return;
+    if (recentIcons == nil)
+        recentIcons = [[NSMutableDictionary alloc] init];
     [recentIcons setObject:icon forKey:pageURLString];
     [iconURLs setObject:iconURLString forKey:pageURLString];
     if (data) {

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



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to