Revision: 28577
http://sourceforge.net/p/bibdesk/svn/28577
Author: hofman
Date: 2024-01-07 22:26:38 +0000 (Sun, 07 Jan 2024)
Log Message:
-----------
use @autoreleasepool block
Modified Paths:
--------------
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVConcreteOperationQueue.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIconOperation.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVInvocationOperation.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVThread.m
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVConcreteOperationQueue.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVConcreteOperationQueue.m
2024-01-07 18:20:29 UTC (rev 28576)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVConcreteOperationQueue.m
2024-01-07 22:26:38 UTC (rev 28577)
@@ -295,57 +295,56 @@
- (void)_runOperationThread:(id)unused;
{
- NSAutoreleasePool *pool = [NSAutoreleasePool new];
-
- if ([NSThread instancesRespondToSelector:@selector(setName:)])
- [[NSThread currentThread] setName:[NSString
stringWithFormat:@"Dedicated thread for %@", self]];
-
- [_threadLock lockWhenCondition:QUEUE_STARTUP];
-
- // pass the queue as info, but don't retain/release it since it will
outlive the source
- CFRunLoopSourceContext1 context = { 1, self, NULL, NULL, NULL, NULL, NULL,
__FVGetQueuePort, __FVQueueMachPerform };
- _threadPort = __FVPortAllocate();
-
- // CFRunLoop dies if this happens, so do the same
- if (MACH_PORT_NULL == _threadPort) HALT;
-
- CFRunLoopRef rl = CFRunLoopGetCurrent();
- union {
- CFRunLoopSourceContext c;
- struct _v1 {
- CFRunLoopSourceContext1 c1;
- unsigned long padding;
- } v1;
- } ctxt_u;
- ctxt_u.v1.c1 = context;
- CFRunLoopSourceRef source = CFRunLoopSourceCreate(NULL, 0, &ctxt_u.c);
- // runloop retains the source, but keep a retain on it until we've called
invalidate
- CFRunLoopAddSource(rl, source, kCFRunLoopDefaultMode);
-
- [_threadLock unlockWithCondition:QUEUE_STARTUP_COMPLETE];
- [_threadLock lockWhenCondition:QUEUE_RUNNING];
-
- do {
+ @autoreleasepool {
- [pool release];
- pool = [NSAutoreleasePool new];
+ if ([NSThread instancesRespondToSelector:@selector(setName:)])
+ [[NSThread currentThread] setName:[NSString
stringWithFormat:@"Dedicated thread for %@", self]];
- // timeout is only here in case the mach port dies
- SInt32 result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 10, TRUE);
- if (kCFRunLoopRunFinished == result || kCFRunLoopRunStopped == result)
- FVAtomicSet(_terminate);
+ [_threadLock lockWhenCondition:QUEUE_STARTUP];
- } while (NO == FVAtomicLoad(_terminate));
+ // pass the queue as info, but don't retain/release it since it will
outlive the source
+ CFRunLoopSourceContext1 context = { 1, self, NULL, NULL, NULL, NULL,
NULL, __FVGetQueuePort, __FVQueueMachPerform };
+ _threadPort = __FVPortAllocate();
+
+ // CFRunLoop dies if this happens, so do the same
+ if (MACH_PORT_NULL == _threadPort) HALT;
+
+ CFRunLoopRef rl = CFRunLoopGetCurrent();
+ union {
+ CFRunLoopSourceContext c;
+ struct _v1 {
+ CFRunLoopSourceContext1 c1;
+ unsigned long padding;
+ } v1;
+ } ctxt_u;
+ ctxt_u.v1.c1 = context;
+ CFRunLoopSourceRef source = CFRunLoopSourceCreate(NULL, 0, &ctxt_u.c);
+ // runloop retains the source, but keep a retain on it until we've
called invalidate
+ CFRunLoopAddSource(rl, source, kCFRunLoopDefaultMode);
+
+ [_threadLock unlockWithCondition:QUEUE_STARTUP_COMPLETE];
+ [_threadLock lockWhenCondition:QUEUE_RUNNING];
+
+ do {
+
+ @autoreleasepool {
+ // timeout is only here in case the mach port dies
+ SInt32 result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 10,
TRUE);
+ if (kCFRunLoopRunFinished == result || kCFRunLoopRunStopped ==
result)
+ FVAtomicSet(_terminate);
+ }
+
+ } while (NO == FVAtomicLoad(_terminate));
- CFRunLoopSourceInvalidate(source);
- CFRelease(source);
+ CFRunLoopSourceInvalidate(source);
+ CFRelease(source);
- mach_port_t port = _threadPort;
- _threadPort = MACH_PORT_NULL;
- __FVPortFree(port);
+ mach_port_t port = _threadPort;
+ _threadPort = MACH_PORT_NULL;
+ __FVPortFree(port);
- [_threadLock unlockWithCondition:QUEUE_TERMINATED];
- [pool release];
+ [_threadLock unlockWithCondition:QUEUE_TERMINATED];
+ }
}
@end
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m 2024-01-07
18:20:29 UTC (rev 28576)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m 2024-01-07
22:26:38 UTC (rev 28577)
@@ -1756,57 +1756,57 @@
- (void)_recacheIconsWithInfo:(NSDictionary *)info
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- // if there's ever any contention, don't block
- if ([_modificationLock tryLock]) {
+ @autoreleasepool {
+ // if there's ever any contention, don't block
+ if ([_modificationLock tryLock]) {
- NSArray *orderedIcons = [info objectForKey:@"orderedIcons"];
- NSArray *orderedURLs = [info objectForKey:@"orderedURLs"];
- NSParameterAssert([orderedIcons count] == [orderedURLs count]);
-
- NSUInteger cnt = [orderedURLs count];
- NSNull *nsnull = [NSNull null];
- bool redisplay = false;
- while (cnt--) {
- id aURL = [orderedURLs objectAtIndex:cnt];
- FVIcon *icon = [orderedIcons objectAtIndex:cnt];
- if (aURL != nsnull && [aURL isFileURL]) {
- _FVControllerFileKey *newKey = [_FVControllerFileKey
newWithURL:aURL];
- _FVControllerFileKey *oldKey = [_modificationSet
member:newKey];
- /*
- Check to see if the icon has cached resources calling
recache. This is of marginal
- benefit, since recache should be cheap in that case, but
avoids redisplay. We can't
- use it to avoid the stat() call, since otherwise the
modification set doesn't get
- populated with initial values.
- */
- if (oldKey && __equal_timespecs(&newKey->_mtimespec,
&oldKey->_mtimespec) == false && [icon canReleaseResources]) {
- [[orderedIcons objectAtIndex:cnt] recache];
- [_modificationSet removeObject:oldKey];
- redisplay = true;
+ NSArray *orderedIcons = [info objectForKey:@"orderedIcons"];
+ NSArray *orderedURLs = [info objectForKey:@"orderedURLs"];
+ NSParameterAssert([orderedIcons count] == [orderedURLs count]);
+
+ NSUInteger cnt = [orderedURLs count];
+ NSNull *nsnull = [NSNull null];
+ bool redisplay = false;
+ while (cnt--) {
+ id aURL = [orderedURLs objectAtIndex:cnt];
+ FVIcon *icon = [orderedIcons objectAtIndex:cnt];
+ if (aURL != nsnull && [aURL isFileURL]) {
+ _FVControllerFileKey *newKey = [_FVControllerFileKey
newWithURL:aURL];
+ _FVControllerFileKey *oldKey = [_modificationSet
member:newKey];
+ /*
+ Check to see if the icon has cached resources calling
recache. This is of marginal
+ benefit, since recache should be cheap in that case, but
avoids redisplay. We can't
+ use it to avoid the stat() call, since otherwise the
modification set doesn't get
+ populated with initial values.
+ */
+ if (oldKey && __equal_timespecs(&newKey->_mtimespec,
&oldKey->_mtimespec) == false && [icon canReleaseResources]) {
+ [[orderedIcons objectAtIndex:cnt] recache];
+ [_modificationSet removeObject:oldKey];
+ redisplay = true;
+ }
+ [_modificationSet addObject:newKey];
+ [newKey release];
}
- [_modificationSet addObject:newKey];
- [newKey release];
}
+
+ [_modificationLock unlock];
+
+ /*
+ When the view calls -recache on an icon, it has to reload the
controller as well.
+ In this case, we know that the URL itself is the same, but the
underlying data
+ has changed. Consequently, setNeedsDisplay:YES should be
sufficient.
+ */
+ if (redisplay)
+ [self
performSelectorOnMainThread:@selector(_setViewNeedsDisplay) withObject:nil
waitUntilDone:NO];
+
}
-
- [_modificationLock unlock];
-
- /*
- When the view calls -recache on an icon, it has to reload the
controller as well.
- In this case, we know that the URL itself is the same, but the
underlying data
- has changed. Consequently, setNeedsDisplay:YES should be sufficient.
- */
- if (redisplay)
- [self performSelectorOnMainThread:@selector(_setViewNeedsDisplay)
withObject:nil waitUntilDone:NO];
-
+ else {
+ #if DEBUG
+ // keep an eye out for this; it gets hit with the test program
during view setup
+ FVLog(@"FileView: called %@ while another call was in progress.",
NSStringFromSelector(_cmd));
+ #endif
+ }
}
- else {
-#if DEBUG
- // keep an eye out for this; it gets hit with the test program during
view setup
- FVLog(@"FileView: called %@ while another call was in progress.",
NSStringFromSelector(_cmd));
-#endif
- }
- [pool release];
}
- (void)_recacheIconsInBackgroundIfNeeded
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIconOperation.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIconOperation.m 2024-01-07
18:20:29 UTC (rev 28576)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIconOperation.m 2024-01-07
22:26:38 UTC (rev 28577)
@@ -85,10 +85,10 @@
- (void)main;
{
if (NO == [self isCancelled]) {
- NSAutoreleasePool *pool = [NSAutoreleasePool new];
- [_icon releaseResources];
- [self finished];
- [pool release];
+ @autoreleasepool {
+ [_icon releaseResources];
+ [self finished];
+ }
}
}
@@ -128,13 +128,13 @@
- (void)main;
{
if (NO == [self isCancelled]) {
- NSAutoreleasePool *pool = [NSAutoreleasePool new];
- [_icon renderForSize:_desiredSize];
- FVIconUpdateOperation *op = [[FVIconUpdateOperation alloc]
initWithIcon:_icon view:_view];
- [[FVOperationQueue mainQueue] addOperation:op];
- [op release];
- [self finished];
- [pool release];
+ @autoreleasepool {
+ [_icon renderForSize:_desiredSize];
+ FVIconUpdateOperation *op = [[FVIconUpdateOperation alloc]
initWithIcon:_icon view:_view];
+ [[FVOperationQueue mainQueue] addOperation:op];
+ [op release];
+ [self finished];
+ }
}
}
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVInvocationOperation.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVInvocationOperation.m
2024-01-07 18:20:29 UTC (rev 28576)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVInvocationOperation.m
2024-01-07 22:26:38 UTC (rev 28577)
@@ -96,14 +96,14 @@
- (void)main
{
- NSAutoreleasePool *pool = [NSAutoreleasePool new];
- @try {
- [_invocation invoke];
+ @autoreleasepool {
+ @try {
+ [_invocation invoke];
+ }
+ @catch (id exception) {
+ _exception = [exception retain];
+ }
}
- @catch (id exception) {
- _exception = [exception retain];
- }
- [pool release];
[self finished];
}
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVThread.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVThread.m 2024-01-07
18:20:29 UTC (rev 28576)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVThread.m 2024-01-07
22:26:38 UTC (rev 28577)
@@ -271,7 +271,7 @@
{
#if DEBUG_REAPER
- NSAutoreleasePool *pool = [NSAutoreleasePool new];
+ @autoreleasepool {
#endif
_FVThread *self = obj;
@@ -331,7 +331,7 @@
}
[self release];
#if DEBUG_REAPER
- [pool release];
+ }
#endif
return NULL;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit