Revision: 12277
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=12277&view=rev
Author:   amaxwell
Date:     2008-01-05 10:46:34 -0800 (Sat, 05 Jan 2008)

Log Message:
-----------
Remove ivar.  Just hold the lock until drawing completes, which has the same
effect.  There's no thumbnail to draw, so there's no point in unlocking.

Modified Paths:
--------------
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.h
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.m

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.h
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.h      2008-01-05 
18:05:50 UTC (rev 12276)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.h      2008-01-05 
18:46:34 UTC (rev 12277)
@@ -50,7 +50,6 @@
     NSURL          *_fileURL;
     BOOL            _inDiskCache;
     char           *_diskCacheName;
-    BOOL            _isRendering;
     BOOL            _drawsLinkBadge;
     pthread_mutex_t _mutex;
 }

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.m      2008-01-05 
18:05:50 UTC (rev 12276)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.m      2008-01-05 
18:46:34 UTC (rev 12277)
@@ -158,7 +158,6 @@
         _thumbnailRef = NULL;
         _inDiskCache = NO;
         _diskCacheName = FVCreateDiskCacheNameWithURL(_fileURL);
-        _isRendering = NO;
         
         NSInteger rc = pthread_mutex_init(&_mutex, NULL);
         if (rc)
@@ -184,9 +183,9 @@
     // if we can't lock we're already rendering, which will give us both icons 
(so no render required)
     if (pthread_mutex_trylock(&_mutex) == 0) {
         if (size.height < _thumbnailSize.height * 1.2)
-            needsRender = (NULL == _thumbnailRef && NO == _isRendering);
+            needsRender = (NULL == _thumbnailRef);
         else 
-            needsRender = (NULL == _fullImageRef && NO == _isRendering);
+            needsRender = (NULL == _fullImageRef);
         pthread_mutex_unlock(&_mutex);
     }
     return needsRender;
@@ -239,8 +238,10 @@
 
 - (void)renderOffscreen
 {
-    // !!! early return here after a cache check
+    // hold the lock to let needsRenderForSize: know that this icon doesn't 
need rendering
     pthread_mutex_lock(&_mutex);
+    
+    // !!! early return here after a cache check
     if (_inDiskCache) {
         CGImageRelease(_fullImageRef);
         _fullImageRef = [FVIconCache newImageNamed:_diskCacheName];
@@ -250,11 +251,8 @@
             return;
         }
     }
+
     
-    // set a flag instead of holding the lock the entire time, since we don't 
use mutable ivars until later
-    _isRendering = YES;
-    pthread_mutex_unlock(&_mutex);
-    
     // definitely use the context cache for this, since these bitmaps are 
pretty huge
     CGContextRef ctxt = [FVBitmapContextCache 
newBitmapContextOfWidth:__paperSize.width height:__paperSize.height];
     
@@ -354,7 +352,6 @@
     // restore the previous context
     [NSGraphicsContext restoreGraphicsState];
     
-    pthread_mutex_lock(&_mutex);
     CGImageRelease(_fullImageRef);
     _fullImageRef = CGBitmapContextCreateImage(ctxt);
     [FVIconCache cacheCGImage:_fullImageRef withName:_diskCacheName];
@@ -388,7 +385,7 @@
         CGContextRestoreGState(ctxt);
         [FVBitmapContextCache disposeOfBitmapContext:ctxt];
     }
-    _isRendering = NO;
+
     pthread_mutex_unlock(&_mutex);
 }    
 


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

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to