Revision: 12596
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=12596&view=rev
Author:   hofman
Date:     2008-01-20 08:20:14 -0800 (Sun, 20 Jan 2008)

Log Message:
-----------
Don't message delegate on notification thread, as this ivar is not thread safe.

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

Modified: trunk/bibdesk/BDSKFileSearchIndex.m
===================================================================
--- trunk/bibdesk/BDSKFileSearchIndex.m 2008-01-20 13:51:32 UTC (rev 12595)
+++ trunk/bibdesk/BDSKFileSearchIndex.m 2008-01-20 16:20:14 UTC (rev 12596)
@@ -58,6 +58,7 @@
 - (void)reindexFileURLsIfNeeded:(NSSet *)urlsToReindex forIdentifierURL:(NSURL 
*)identifierURL;
 - (void)runIndexThreadForItems:(NSArray *)items;
 - (void)searchIndexDidUpdate;
+- (void)searchIndexDidFinishInitialIndexing;
 - (void)processNotification:(NSNotification *)note;
 - (void)handleDocAddItemNotification:(NSNotification *)note;
 - (void)handleDocDelItemNotification:(NSNotification *)note;
@@ -332,7 +333,7 @@
                     pthread_rwlock_unlock(&rwlock);
                     [indexedIdentifierURLs removeAllObjects];
                     
-                    [[OFMessageQueue mainQueue] 
queueSelectorOnce:@selector(searchIndexDidUpdate:) forObject:delegate 
withObject:self];
+                    [[OFMessageQueue mainQueue] 
queueSelectorOnce:@selector(searchIndexDidUpdate) forObject:self 
withObject:nil];
                     countSinceLastFlush = flushInterval;
                 }
             }
@@ -357,7 +358,7 @@
         }
         [URLsToRemove release];
         
-        [self searchIndexDidUpdate];
+        [self performSelectorOnMainThread:@selector(searchIndexDidUpdate) 
withObject:nil waitUntilDone:NO];
         
         [items release];
         items = itemsToAdd;
@@ -375,7 +376,7 @@
 
     OSMemoryBarrier();
     if (flags.shouldKeepRunning == 1)
-        [delegate 
performSelectorOnMainThread:@selector(searchIndexDidFinishInitialIndexing:) 
withObject:self waitUntilDone:NO];
+        [self 
performSelectorOnMainThread:@selector(searchIndexDidFinishInitialIndexing) 
withObject:nil waitUntilDone:NO];
 }
 
 - (void)indexFileURL:(NSURL *)aURL{
@@ -443,7 +444,7 @@
             [pool release];
             pool = [NSAutoreleasePool new];
             
-            [self searchIndexDidUpdate];
+            [self performSelectorOnMainThread:@selector(searchIndexDidUpdate) 
withObject:nil waitUntilDone:NO];
             countSinceLastFlush = flushInterval;
         }
         OSMemoryBarrier();
@@ -454,7 +455,7 @@
     // final update to catch any leftovers
     
     // it's possible that we've been told to stop, and the delegate is 
garbage; in that case, don't message it
-    [self searchIndexDidUpdate];
+    [self performSelectorOnMainThread:@selector(searchIndexDidUpdate) 
withObject:nil waitUntilDone:NO];
     [pool release];
 }
 
@@ -613,11 +614,20 @@
 
 - (void)searchIndexDidUpdate
 {
+    OBASSERT([NSThread inMainThread]);
     OSMemoryBarrier();
     if (flags.shouldKeepRunning == 1)
-        [delegate performSelectorOnMainThread:@selector(searchIndexDidUpdate:) 
withObject:self waitUntilDone:NO];
+        [delegate searchIndexDidUpdate:self];
 }
 
+- (void)searchIndexDidFinishInitialIndexing
+{
+    OBASSERT([NSThread inMainThread]);
+    OSMemoryBarrier();
+    if (flags.shouldKeepRunning == 1)
+        [delegate searchIndexDidFinishInitialIndexing:self];
+}
+
 - (void)processNotification:(NSNotification *)note
 {    
     OBASSERT([NSThread inMainThread]);
@@ -660,7 +670,7 @@
        }
     OSAtomicCompareAndSwap32Barrier(1, 0, (int32_t *)&flags.isIndexing);
        
-    [self searchIndexDidUpdate];
+    [self performSelectorOnMainThread:@selector(searchIndexDidUpdate) 
withObject:nil waitUntilDone:NO];
 }
 
 - (void)handleSearchIndexInfoChangedNotification:(NSNotification *)note
@@ -710,7 +720,7 @@
     [addedURLs release];
     [sameURLs release];
     
-    [self searchIndexDidUpdate];
+    [self performSelectorOnMainThread:@selector(searchIndexDidUpdate) 
withObject:nil waitUntilDone:NO];
 }    
 
 - (void)handleMachMessage:(void *)msg


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 2008.
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