Revision: 28414
http://sourceforge.net/p/bibdesk/svn/28414
Author: hofman
Date: 2023-11-04 00:33:09 +0000 (Sat, 04 Nov 2023)
Log Message:
-----------
Set deployment target of fileview to 10.13. Replace deprecated symbols,
methods, and functions.
Modified Paths:
--------------
trunk/bibdesk_vendorsrc/amaxwell/FileView/Configurations/FileView-Common.xcconfig
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVAccessibilityIconElement.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVArrowButtonCell.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageCache.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageUtilities.mm
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCacheFile.mm
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVColorMenuView.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVConcreteOperationQueue.h
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVConcreteOperationQueue.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVDownload.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVImageBuffer.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVInvocationOperation.h
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVMIMEIcon.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVOperation.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPreviewer.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVScaledImageView.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVSlider.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVThread.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/_FVMappedDataProvider.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/_FVPreviewerWindow.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/fv_zone.cpp
Modified:
trunk/bibdesk_vendorsrc/amaxwell/FileView/Configurations/FileView-Common.xcconfig
===================================================================
---
trunk/bibdesk_vendorsrc/amaxwell/FileView/Configurations/FileView-Common.xcconfig
2023-11-03 22:43:04 UTC (rev 28413)
+++
trunk/bibdesk_vendorsrc/amaxwell/FileView/Configurations/FileView-Common.xcconfig
2023-11-04 00:33:09 UTC (rev 28414)
@@ -1,7 +1,7 @@
ARCHS = $(ARCHS_STANDARD)
SDKROOT = macosx
SKIP_INSTALL = YES
-MACOSX_DEPLOYMENT_TARGET = 10.9
+MACOSX_DEPLOYMENT_TARGET = 10.13
IBC_STRIP_NIBS = NO
ZERO_LINK = NO
COMBINE_HIDPI_IMAGES = YES
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVAccessibilityIconElement.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVAccessibilityIconElement.m
2023-11-03 22:43:04 UTC (rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVAccessibilityIconElement.m
2023-11-04 00:33:09 UTC (rev 28414)
@@ -178,21 +178,17 @@
- (id)accessibilityWindow {
// We're in the same window as our parent.
- id parent = [self accessibilityParent];
+ id parent = NSAccessibilityUnignoredAncestor([self accessibilityParent]);
if ([parent respondsToSelector:_cmd])
- return [NSAccessibilityUnignoredAncestor(_parent) accessibilityWindow];
- else if ([parent
respondsToSelector:@selector(accessibilityAttributeValue:)])
- return [parent
accessibilityAttributeValue:NSAccessibilityWindowAttribute];
+ return [_parent accessibilityWindow];
return nil;
}
- (id)accessibilityTopLevelUIElement {
// We're in the same top level element as our parent.
- id parent = [self accessibilityParent];
+ id parent = NSAccessibilityUnignoredAncestor([self accessibilityParent]);
if ([parent respondsToSelector:_cmd])
- return [NSAccessibilityUnignoredAncestor(_parent)
accessibilityTopLevelUIElement];
- else if ([parent
respondsToSelector:@selector(accessibilityAttributeValue:)])
- return [parent
accessibilityAttributeValue:NSAccessibilityTopLevelUIElementAttribute];
+ return [_parent accessibilityTopLevelUIElement];
return nil;
}
@@ -208,7 +204,7 @@
if (title == nil)
title = [aURL lastPathComponent];
} else {
- title = [[aURL absoluteString]
stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+ title = [[aURL absoluteString] stringByRemovingPercentEncoding];
}
return title;
}
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVArrowButtonCell.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVArrowButtonCell.m
2023-11-03 22:43:04 UTC (rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVArrowButtonCell.m
2023-11-04 00:33:09 UTC (rev 28414)
@@ -144,10 +144,10 @@
}
if (keepOn) {
// we're dragging outside the button, wait for a mouseup or
move back inside
- theEvent = [[controlView window] nextEventMatchingMask:
NSLeftMouseUpMask | NSLeftMouseDraggedMask];
+ theEvent = [[controlView window] nextEventMatchingMask:
NSEventMaskLeftMouseUp | NSEventMaskLeftMouseDragged];
mouseLoc = [controlView convertPoint:[theEvent
locationInWindow] fromView:nil];
isInside = NSMouseInRect(mouseLoc, cellFrame, [controlView
isFlipped]);
- keepOn = ([theEvent type] == NSLeftMouseDragged);
+ keepOn = ([theEvent type] == NSEventMaskLeftMouseDragged);
}
}
return isInside;
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageCache.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageCache.m 2023-11-03
22:43:04 UTC (rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageCache.m 2023-11-04
00:33:09 UTC (rev 28414)
@@ -42,7 +42,6 @@
#import "FVCacheFile.h"
#import "FVAllocator.h"
-#import <libkern/OSAtomic.h>
#import <pthread.h>
static CGImageRef FVCreateCGImageWithData(NSData *data);
@@ -186,7 +185,7 @@
toReturn = CGImageSourceCreateImageAtIndex(imsrc, 0, NULL);
if (imsrc) CFRelease(imsrc);
#else
- NSUnarchiver *unarchiver = [[NSUnarchiver allocWithZone:FVDefaultZone()]
initForReadingWithData:data];
+ NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver
allocWithZone:FVDefaultZone()] initForReadingWithData:data];
// only retained by unarchiver
FVCGImageDescription *imageDescription = [unarchiver decodeObject];
toReturn = [imageDescription newImage];
@@ -211,7 +210,7 @@
size_t approximateLength = CGImageGetBytesPerRow(image) *
CGImageGetHeight(image) + 20 * sizeof(size_t);
NSMutableData *mdata = [[NSMutableData allocWithZone:FVDefaultZone()]
initWithCapacity:approximateLength];
- NSArchiver *archiver = [[NSArchiver allocWithZone:FVDefaultZone()]
initForWritingWithMutableData:(NSMutableData *)mdata];
+ NSKeyedArchiver *archiver = [[NSKeyedArchiver
allocWithZone:FVDefaultZone()] initForWritingWithMutableData:(NSMutableData
*)mdata];
[archiver encodeObject:imageDescription];
[imageDescription release];
[archiver release];
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageUtilities.mm
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageUtilities.mm
2023-11-03 22:43:04 UTC (rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageUtilities.mm
2023-11-04 00:33:09 UTC (rev 28414)
@@ -42,7 +42,6 @@
#import "FVImageBuffer.h"
#import <Accelerate/Accelerate.h>
-#import <libkern/OSAtomic.h>
#import <sys/time.h>
#import <vector>
@@ -347,7 +346,7 @@
CGColorSpaceGetColorTable(cspace, table);
FVImageBuffer *planarBuffers[4];
- [buffers getObjects:planarBuffers];
+ [buffers getObjects:planarBuffers range:NSMakeRange(0, [buffers count])];
// set sizes to avoid a mismatch; these are guaranteed to be large enough
for (NSUInteger i = 0; i < sizeof(planarBuffers) / sizeof(FVImageBuffer
*); i++) {
@@ -410,7 +409,7 @@
vImage_Error ret;
FVImageBuffer *planarBuffers[4];
- [buffers getObjects:planarBuffers];
+ [buffers getObjects:planarBuffers range:NSMakeRange(0, [buffers count])];
// set sizes to avoid a mismatch; these are guaranteed to be large enough
for (NSUInteger i = 0; i < sizeof(planarBuffers) / sizeof(FVImageBuffer
*); i++) {
@@ -475,7 +474,7 @@
vImage_Error ret;
FVImageBuffer *planarBuffers[4];
- [buffers getObjects:planarBuffers];
+ [buffers getObjects:planarBuffers range:NSMakeRange(0, [buffers count])];
// set sizes to avoid a mismatch; these are guaranteed to be large enough
for (NSUInteger i = 0; i < sizeof(planarBuffers) / sizeof(FVImageBuffer
*); i++) {
@@ -633,7 +632,7 @@
NSCParameterAssert([planarBuffers count] == 4);
const FVImageBuffer *planarA[4];
- [planarBuffers getObjects:planarA];
+ [planarBuffers getObjects:planarA range:NSMakeRange(0, [planarBuffers
count])];
vImage_Error ret;
@@ -876,10 +875,10 @@
imageBuffer = nil;
const FVImageBuffer *planarA[4];
- [planarTilesA getObjects:planarA];
+ [planarTilesA getObjects:planarA range:NSMakeRange(0, [planarTilesA
count])];
const FVImageBuffer *planarB[4];
- [planarTilesB getObjects:planarB];
+ [planarTilesB getObjects:planarB range:NSMakeRange(0, [planarTilesB
count])];
// keep track of the next scanline/byte offset in the final image
NSUInteger nextScanline = 0;
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCacheFile.mm
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCacheFile.mm 2023-11-03
22:43:04 UTC (rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCacheFile.mm 2023-11-04
00:33:09 UTC (rev 28414)
@@ -40,10 +40,10 @@
#import "FVUtilities.h"
#import "FVAllocator.h"
-#import <libkern/OSAtomic.h>
#import <string>
#import <sys/stat.h>
#import <asl.h>
+#import <os/log.h>
#import <zlib.h>
#import <sys/mman.h>
@@ -86,6 +86,8 @@
static NSInteger FVCacheLogLevel = 0;
+static os_log_t logger;
+
+ (void)initialize
{
FVINITIALIZE(FVCacheFile);
@@ -94,7 +96,10 @@
// 0 - disabled
// 1 - only print final stats
// 2 - print URL each as it's added
- FVCacheLogLevel = [[NSUserDefaults standardUserDefaults]
integerForKey:@"FVCacheLogLevel"];
+ FVCacheLogLevel = [[NSUserDefaults standardUserDefaults]
integerForKey:@"FVCacheLogLevel"];
+
+ if (FVCacheLogLevel > 0)
+ logger = os_log_create("com.mac.amaxwell.fileview", "FileViewCache");
}
#pragma clang diagnostic push
@@ -190,14 +195,9 @@
off_t fsize = sb.st_size;
double mbSize = double(fsize) / 1024 / 1024;
- aslclient client = asl_open("FileViewCache", NULL,
ASL_OPT_NO_DELAY);
- aslmsg m = asl_new(ASL_TYPE_MSG);
- asl_set(m, ASL_KEY_SENDER, "FileViewCache");
const char *cacheName = [_cacheName UTF8String];
- asl_log(client, m, ASL_LEVEL_ERR, "%s: removing %s with cache size
= %.2f MB\n", cacheName, path, mbSize);
- asl_log(client, m, ASL_LEVEL_ERR, "%s: final cache content
(compressed): %s\n", cacheName, [[_eventTable description] UTF8String]);
- asl_free(m);
- asl_close(client);
+ os_log_error(logger, "%s: removing %s with cache size = %.2f
MB\n", cacheName, path, mbSize);
+ os_log_error(logger, "%s: final cache content (compressed): %s\n",
cacheName, [[_eventTable description] UTF8String]);
}
else {
std::string errMsg = std::string("stat failed \"") + path + "\"";
@@ -270,12 +270,7 @@
if (scheme) CFRelease(scheme);
if (FVCacheLogLevel > 1) {
- aslclient client = asl_open("FileViewCache", NULL, ASL_OPT_NO_DELAY);
- aslmsg m = asl_new(ASL_TYPE_MSG);
- asl_set(m, ASL_KEY_SENDER, "FileViewCache");
- asl_log(client, m, ASL_LEVEL_ERR, "caching image for %s, size = %.2f
kBytes\n", [[key description] UTF8String], kbytes);
- asl_free(m);
- asl_close(client);
+ os_log_error(logger, "caching image for %s, size = %.2f kBytes\n",
[[key description] UTF8String], kbytes);
}
}
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVColorMenuView.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVColorMenuView.m 2023-11-03
22:43:04 UTC (rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVColorMenuView.m 2023-11-04
00:33:09 UTC (rev 28414)
@@ -94,7 +94,7 @@
[_labelCell setFont:[NSFont menuBarFontOfSize:0.0]];
_labelNameCell = [[NSTextFieldCell alloc] initTextCell:@""];
- [_labelNameCell setAlignment:NSCenterTextAlignment];
+ [_labelNameCell setAlignment:NSTextAlignmentCenter];
if (floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_10)
{
[_labelNameCell setFont:[NSFont boldSystemFontOfSize:[NSFont
smallSystemFontSize]]];
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVConcreteOperationQueue.h
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVConcreteOperationQueue.h
2023-11-03 22:43:04 UTC (rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVConcreteOperationQueue.h
2023-11-04 00:33:09 UTC (rev 28414)
@@ -40,6 +40,7 @@
#import "FVOperationQueue.h"
#import <pthread.h>
#import <mach/port.h>
+#import <stdatomic.h>
@class FVOperation, FVPriorityQueue;
@@ -49,7 +50,7 @@
@interface FVConcreteOperationQueue : FVOperationQueue
{
@private
- volatile int32_t _terminate;
+ _Atomic(BOOL) _terminate;
mach_port_t _threadPort;
NSConditionLock *_threadLock;
pthread_mutex_t _queueLock;
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVConcreteOperationQueue.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVConcreteOperationQueue.m
2023-11-03 22:43:04 UTC (rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVConcreteOperationQueue.m
2023-11-04 00:33:09 UTC (rev 28414)
@@ -63,15 +63,15 @@
// Threading parameters. 20 seems high, but I tried using NSOperationQueue
and ended up spawning 70+ threads with no problems. Most of them just block
while waiting for ATS font data (at least in the PDF case), but we could end up
with some disk thrash while reading (need to check this). A recommendation by
Chris Kane http://www.cocoabuilder.com/archive/message/cocoa/2008/2/1/197773
indicates that dumping all the operations in the queue and letting the kernel
sort out resource allocation is a reasonable approach, since we don't know a
prioi which operations will be fast or slow.
-static volatile int32_t _activeQueueCount = 0;
-static volatile int32_t _activeCPUs = 0;
+static _Atomic(int32_t) _activeQueueCount = 0;
+static _Atomic(int32_t) _activeCPUs = 0;
// Allow a maximum of 10 operations per active CPU core and a minimum of 2 per
core; untuned. Main idea here is to keep from killing performance by creating
too many threads or operations, but memory/disk are also big factors that are
unaccounted for here.
+ (NSUInteger)_availableOperationCount
{
- int32_t maxConcurrentOperations = _activeCPUs * 10;
+ int32_t maxConcurrentOperations = atomic_load(&_activeCPUs) * 10;
int32_t minConcurrentOperations = 2;
- return MAX((maxConcurrentOperations - ((_activeQueueCount - 1) *
minConcurrentOperations)), minConcurrentOperations);
+ return MAX((maxConcurrentOperations - (atomic_load(&_activeQueueCount - 1)
* minConcurrentOperations)), minConcurrentOperations);
}
+ (void)_updateKernelInfo:(id)unused
@@ -87,7 +87,7 @@
if (sysctlbyname("hw.activecpu", &activeCPUs, &size, NULL, 0) == 0)
numberOfCPUs = activeCPUs;
}
- OSAtomicCompareAndSwap32Barrier(_activeCPUs, numberOfCPUs, &_activeCPUs);
+ atomic_store(&_activeCPUs, numberOfCPUs);
}
+ (void)initialize
@@ -129,7 +129,7 @@
[_threadLock lockWhenCondition:QUEUE_STARTUP_COMPLETE];
[_threadLock unlockWithCondition:QUEUE_RUNNING];
- OSAtomicIncrement32Barrier(&_activeQueueCount);
+ atomic_fetch_add(&_activeQueueCount, 1);
}
return self;
@@ -137,7 +137,7 @@
- (void)dealloc
{
- FVAPIAssert1(1 == _terminate, @"*** ERROR *** attempt to deallocate %@
without calling -terminate", self);
+ FVAPIAssert1(YES == atomic_load(&_terminate), @"*** ERROR *** attempt to
deallocate %@ without calling -terminate", self);
[_threadLock release];
[_pendingOperations release];
[_activeOperations release];
@@ -199,7 +199,7 @@
ret = __FVSendTrivialMachMessage(_threadPort, 0, MACH_SEND_TIMEOUT, 0);
if (ret != MACH_MSG_SUCCESS && ret != MACH_SEND_TIMED_OUT) {
// we can ignore MACH_SEND_INVALID_DEST when terminating
- if (MACH_SEND_INVALID_DEST != ret || 1 != _terminate) HALT;
+ if (MACH_SEND_INVALID_DEST != ret || YES != atomic_load(&_terminate))
HALT;
}
}
@@ -252,10 +252,10 @@
- (void)terminate
{
- OSAtomicDecrement32Barrier(&_activeQueueCount);
+ atomic_fetch_sub(&_activeQueueCount, 1);
[[NSNotificationCenter defaultCenter] removeObserver:self];
[self cancel];
- OSAtomicCompareAndSwap32Barrier(0, 1, &_terminate);
+ atomic_store(&_terminate, YES);
[self _wakeThread];
[_threadLock lockWhenCondition:QUEUE_TERMINATED];
[_threadLock unlock];
@@ -333,9 +333,9 @@
// timeout is only here in case the mach port dies
SInt32 result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 10, TRUE);
if (kCFRunLoopRunFinished == result || kCFRunLoopRunStopped == result)
- OSAtomicCompareAndSwap32Barrier(0, 1, &_terminate);
+ atomic_store(&_terminate, YES);
- } while (0 == _terminate);
+ } while (NO == atomic_load(&_terminate));
CFRunLoopSourceInvalidate(source);
CFRelease(source);
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVDownload.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVDownload.m 2023-11-03
22:43:04 UTC (rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVDownload.m 2023-11-04
00:33:09 UTC (rev 28414)
@@ -128,7 +128,10 @@
- (void)start
{
NSAssert1(nil == _download, @"Error: already called -start on %@", self);
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
_download = [[WebDownload alloc] initWithRequest:[NSURLRequest
requestWithURL:[self downloadURL]] delegate:self];
+#pragma clang diagnostic pop
}
- (void)cancel
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m 2023-11-03
22:43:04 UTC (rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m 2023-11-04
00:33:09 UTC (rev 28414)
@@ -363,7 +363,7 @@
[_titleCell setFont:[NSFont systemFontOfSize:12.0]];
[_titleCell setTextColor:[NSColor
respondsToSelector:@selector(labelColor)] ? [NSColor labelColor] : [NSColor
darkGrayColor]];
[_titleCell setLineBreakMode:NSLineBreakByTruncatingTail];
- [_titleCell setAlignment:NSCenterTextAlignment];
+ [_titleCell setAlignment:NSTextAlignmentCenter];
// @@ Dark mode
@@ -371,7 +371,7 @@
[_subtitleCell setFont:[NSFont systemFontOfSize:10.0]];
[_subtitleCell setTextColor:[NSColor
respondsToSelector:@selector(secondaryLabelColor)] ? [NSColor
secondaryLabelColor] : [NSColor grayColor]];
[_subtitleCell setLineBreakMode:NSLineBreakByTruncatingTail];
- [_subtitleCell setAlignment:NSCenterTextAlignment];
+ [_subtitleCell setAlignment:NSTextAlignmentCenter];
_leftArrow = [[FVArrowButtonCell alloc]
initWithArrowDirection:FVArrowLeft];
[_leftArrow setTarget:self];
@@ -2167,7 +2167,7 @@
// @@ Dark mode
[[NSColor colorWithCalibratedWhite:1.0 alpha:0.3] setFill];
NSRect r = [self centerScanRect:NSInsetRect(_rubberBandRect, 0.5, 0.5)];
- NSRectFillUsingOperation(r, NSCompositeSourceOver);
+ NSRectFillUsingOperation(r, NSCompositingOperationSourceOver);
// NSFrameRect doesn't respect setStroke
[[NSColor lightGrayColor] setFill];
NSFrameRectWithWidth(r, 1.0);
@@ -2182,7 +2182,7 @@
NSBundle *bundle = [NSBundle bundleForClass:[FVFileView class]];
NSString *message = NSLocalizedStringFromTableInBundle(@"Drop Files Here",
@"FileView", bundle, @"placeholder message for empty file view");
NSMutableParagraphStyle *ps = [[NSParagraphStyle defaultParagraphStyle]
mutableCopy];
- [ps setAlignment:NSCenterTextAlignment];
+ [ps setAlignment:NSTextAlignmentCenter];
NSDictionary *attributes = [NSDictionary
dictionaryWithObjectsAndKeys:[NSFont boldSystemFontOfSize:fontSize],
NSFontAttributeName, ps, NSParagraphStyleAttributeName, nil];
NSMutableAttributedString *attrString = [[[NSMutableAttributedString
alloc] initWithString:message attributes:attributes] autorelease];
[ps release];
@@ -2576,7 +2576,7 @@
// any solid color background should override the gradient code
if ([self backgroundColor]) {
[[self backgroundColor] setFill];
- NSRectFillUsingOperation(rect, NSCompositeSourceOver);
+ NSRectFillUsingOperation(rect, NSCompositingOperationSourceOver);
}
else {
/*
@@ -3099,7 +3099,7 @@
- (void)scrollWheel:(NSEvent *)event
{
// Run in NSEventTrackingRunLoopMode for scroll wheel events, in order to
avoid continuous tracking/tooltip rect resets while scrolling.
- while ((event = [NSApp nextEventMatchingMask:NSScrollWheelMask
untilDate:[NSDate dateWithTimeIntervalSinceNow:0.5]
inMode:NSEventTrackingRunLoopMode dequeue:YES]))
+ while ((event = [NSApp nextEventMatchingMask:NSEventMaskScrollWheel
untilDate:[NSDate dateWithTimeIntervalSinceNow:0.5]
inMode:NSEventTrackingRunLoopMode dequeue:YES]))
[super scrollWheel:event];
}
@@ -3294,7 +3294,7 @@
if (name == nil)
name = [[theURL path] lastPathComponent];
} else {
- name = [[theURL absoluteString]
stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+ name = [[theURL absoluteString] stringByRemovingPercentEncoding];
}
if (isTitle && [_dataSource
respondsToSelector:@selector(fileView:subtitleAtIndex:)]) {
NSString *subtitle = [self subtitleAtIndex:i];
@@ -3324,7 +3324,7 @@
switch(ch) {
case 0x0020:
- if ((flags & NSShiftKeyMask) != 0)
+ if ((flags & NSEventModifierFlagShift) != 0)
[[self enclosingScrollView] pageUp:self];
else
[[self enclosingScrollView] pageDown:self];
@@ -3367,7 +3367,7 @@
if ([_selectionIndexes containsIndex:i] == NO) {
// deselect all if modifier key was not pressed, or i == NSNotFound
- if ((flags & (NSCommandKeyMask | NSShiftKeyMask)) == 0 ||
NSNotFound == i)
+ if ((flags & (NSEventModifierFlagCommand |
NSEventModifierFlagShift)) == 0 || NSNotFound == i)
newSelection = [[NSMutableIndexSet alloc] init];
else
newSelection = [_selectionIndexes mutableCopy];
@@ -3376,10 +3376,10 @@
if (NSNotFound != i) {
// add a single index for an unmodified or cmd-click
// add a single index for shift click only if there is no
current selection
- if ((flags & NSShiftKeyMask) == 0 || [newSelection count] ==
0) {
+ if ((flags & NSEventModifierFlagShift) == 0 || [newSelection
count] == 0) {
[newSelection addIndex:i];
}
- else if ((flags & NSShiftKeyMask) != 0) {
+ else if ((flags & NSEventModifierFlagShift) != 0) {
// Shift-click extends by a region; this is equivalent to
iPhoto's grid view. Finder treats shift-click like cmd-click in icon view, but
we have a fixed layout, so this behavior is convenient and will be predictable.
// at this point, we know that [_selectionIndexes count] > 0
@@ -3404,7 +3404,7 @@
}
}
}
- else if ((flags & NSCommandKeyMask) != 0) {
+ else if ((flags & NSEventModifierFlagCommand) != 0) {
// cmd-clicked a previously selected index, so remove it from the
selection
newSelection = [_selectionIndexes mutableCopy];
[newSelection removeIndex:i];
@@ -3420,7 +3420,7 @@
// change selection first, as Finder does
if ([event clickCount] > 1 && i != NSNotFound) {
- if (flags & NSAlternateKeyMask) {
+ if (flags & NSEventModifierFlagOption) {
NSURL *aURL = [self URLAtIndex:i];
if (aURL && NO == [aURL isEqual:[FVIcon missingFileURL]])
[self _previewURL:aURL forIconInRect:[self
_rectOfIconInRow:r column:c]];
@@ -4033,7 +4033,7 @@
- (NSMenu *)menuForIconAtIndex:(NSUInteger)idx
{
- NSMenu *menu = [[[[self class] defaultMenu] copyWithZone:[NSMenu
menuZone]] autorelease];
+ NSMenu *menu = [[[[self class] defaultMenu] copy] autorelease];
// Finder changes selection only if the clicked item isn't in the current
selection
if (menu && NO == [_selectionIndexes containsIndex:idx])
@@ -4134,7 +4134,7 @@
if (nil == sharedMenu) {
NSMenuItem *anItem;
- sharedMenu = [[NSMenu allocWithZone:[NSMenu menuZone]]
initWithTitle:@""];
+ sharedMenu = [[NSMenu alloc] initWithTitle:@""];
NSBundle *bundle = [NSBundle bundleForClass:[FVFileView class]];
anItem = [sharedMenu
addItemWithTitle:NSLocalizedStringFromTableInBundle(@"Quick Look", @"FileView",
bundle, @"context menu title") action:@selector(previewAction:)
keyEquivalent:@""];
@@ -4525,7 +4525,7 @@
since it doesn't frob the responder chain like QLPreviewPanel. This is
enough of an edge
case that it's not worth a great deal of trouble, though.
*/
- if ([event type] == NSKeyDown) {
+ if ([event type] == NSEventTypeKeyDown) {
[self interpretKeyEvents:[NSArray arrayWithObject:event]];
return YES;
}
@@ -4872,7 +4872,7 @@
NSRange range = [name rangeOfString:@"://"];
if (range.location != NSNotFound)
name = [name substringFromIndex:NSMaxRange(range)];
- _name = [[name
stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
copyWithZone:[self zone]];
+ _name = [[name stringByRemovingPercentEncoding] copyWithZone:[self
zone]];
}
_label = [FVFinderLabel finderLabelForURL:aURL];
}
@@ -5147,7 +5147,7 @@
// any solid color background should override the gradient code
if (backgroundColor) {
[backgroundColor setFill];
- NSRectFillUsingOperation(rect, NSCompositeSourceOver);
+ NSRectFillUsingOperation(rect, NSCompositingOperationSourceOver);
}
else {
/*
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon.m 2023-11-03 22:43:04 UTC
(rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon.m 2023-11-04 00:33:09 UTC
(rev 28414)
@@ -66,7 +66,7 @@
FVIconClass = self;
_placeholderIcon = (FVPlaceholderIcon
*)NSAllocateObject([FVPlaceholderIcon self], 0, NSDefaultMallocZone());
- _missingFileURL = [[NSURL alloc] initWithScheme:@"x-fileview"
host:@"localhost" path:@"/missing"];
+ _missingFileURL = [[NSURL alloc]
initWithString:@"x-fileview://localhost/missing"];
[self _initializeCategory];
}
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVImageBuffer.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVImageBuffer.m 2023-11-03
22:43:04 UTC (rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVImageBuffer.m 2023-11-04
00:33:09 UTC (rev 28414)
@@ -39,14 +39,14 @@
#import "FVImageBuffer.h"
#import "FVUtilities.h"
#import "FVCGImageUtilities.h"
-#import <libkern/OSAtomic.h>
+#import <stdatomic.h>
#import "FVBitmapContext.h"
#import "FVAllocator.h"
#if __LP64__
-static volatile uint64_t _allocatedBytes = 0;
+static _Atomic(uint64_t) _allocatedBytes = 0;
#else
-static volatile uint32_t _allocatedBytes = 0;
+static _Atomic(uint32_t) _allocatedBytes = 0;
#endif
@implementation FVImageBuffer
@@ -53,7 +53,7 @@
+ (uint64_t)allocatedBytes
{
- return _allocatedBytes;
+ return atomic_load(&_allocatedBytes);
}
- (id)init
@@ -78,16 +78,7 @@
buffer->rowBytes = bufferSize;
_bufferSize = bufferSize;
buffer->data = CFAllocatorAllocate([self allocator], bufferSize,
0);
- bool swap;
-#if __LP64__
- do {
- swap = OSAtomicCompareAndSwap64Barrier(_allocatedBytes,
_allocatedBytes + _bufferSize, (int64_t *)&_allocatedBytes);
- } while (false == swap);
-#else
- do {
- swap = OSAtomicCompareAndSwap32Barrier(_allocatedBytes,
_allocatedBytes + _bufferSize, (int32_t *)&_allocatedBytes);
- } while (false == swap);
-#endif
+ atomic_fetch_add(&_allocatedBytes, _bufferSize);
if (NULL == buffer->data) {
[self release];
self = nil;
@@ -129,16 +120,7 @@
- (void)dealloc
{
if (_freeBufferOnDealloc) CFAllocatorDeallocate([self allocator],
buffer->data);
- bool swap;
-#if __LP64__
- do {
- swap = OSAtomicCompareAndSwap64Barrier(_allocatedBytes,
_allocatedBytes - _bufferSize, (int64_t *)&_allocatedBytes);
- } while (false == swap);
-#else
- do {
- swap = OSAtomicCompareAndSwap32Barrier(_allocatedBytes,
_allocatedBytes - _bufferSize, (int32_t *)&_allocatedBytes);
- } while (false == swap);
-#endif
+ atomic_fetch_sub(&_allocatedBytes, _bufferSize);
if (buffer != NULL) NSZoneFree([self zone], buffer);
[super dealloc];
}
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVInvocationOperation.h
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVInvocationOperation.h
2023-11-03 22:43:04 UTC (rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVInvocationOperation.h
2023-11-04 00:33:09 UTC (rev 28414)
@@ -38,7 +38,6 @@
#import <Cocoa/Cocoa.h>
#import "FVOperation.h"
-#import <libkern/OSAtomic.h>
/** @internal @brief FVOperation subclass wraps NSInvocation
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVMIMEIcon.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVMIMEIcon.m 2023-11-03
22:43:04 UTC (rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVMIMEIcon.m 2023-11-04
00:33:09 UTC (rev 28414)
@@ -96,7 +96,7 @@
// slight inset and draw partially transparent
NSRect networkRect = NSInsetRect(iconRect, iconRect.size.width / 5.0,
iconRect.size.height / 5.0);
- [_networkIcon drawInRect:networkRect fromRect:NSZeroRect
operation:NSCompositeSourceOver fraction:0.6];
+ [_networkIcon drawInRect:networkRect fromRect:NSZeroRect
operation:NSCompositingOperationSourceOver fraction:0.6];
[NSGraphicsContext restoreGraphicsState];
}
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVOperation.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVOperation.m 2023-11-03
22:43:04 UTC (rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVOperation.m 2023-11-04
00:33:09 UTC (rev 28414)
@@ -39,14 +39,14 @@
#import "FVOperation.h"
#import "FVOperationQueue.h"
#import "FVThread.h"
-#import <libkern/OSAtomic.h>
+#import <stdatomic.h>
struct FVOpFlags {
- volatile int32_t _cancelled;
- volatile int32_t _priority;
- volatile int32_t _executing;
- volatile int32_t _finished;
- volatile int32_t _concurrent;
+ _Atomic(int32_t) _cancelled;
+ _Atomic(int32_t) _priority;
+ _Atomic(int32_t) _executing;
+ _Atomic(int32_t) _finished;
+ _Atomic(int32_t) _concurrent;
};
@implementation FVOperation
@@ -88,31 +88,28 @@
}
- (FVOperationQueuePriority)queuePriority {
- return _flags->_priority;
+ return atomic_load(&(_flags->_priority));
};
- (void)setQueuePriority:(FVOperationQueuePriority)queuePriority {
- bool didSwap;
- do {
- didSwap = OSAtomicCompareAndSwap32Barrier(_flags->_priority,
queuePriority, &(_flags->_priority));
- } while (false == didSwap);
+ atomic_store(&(_flags->_priority), queuePriority);
};
- (void)cancel {
// allow multiple calls to -cancel
- OSAtomicIncrement32Barrier(&(_flags->_cancelled));
+ atomic_fetch_add(&(_flags->_cancelled), 1);
};
- (BOOL)isCancelled {
- return 0 != _flags->_cancelled;
+ return 0 != atomic_load(&(_flags->_cancelled));
};
- (BOOL)isExecuting {
- return 1 == _flags->_executing;
+ return 1 == atomic_load(&(_flags->_executing));
};
- (BOOL)isFinished {
- return 1 == _flags->_finished;
+ return 1 == atomic_load(&(_flags->_finished));
};
- (void)main { [self doesNotRecognizeSelector:_cmd]; }
@@ -128,7 +125,7 @@
};
- (BOOL)isConcurrent {
- return 1 == _flags->_concurrent;
+ return 1 == atomic_load(&(_flags->_concurrent));
}
- (void)setConcurrent:(BOOL)flag {
@@ -137,11 +134,8 @@
if ([self isExecuting] || [self isFinished])
[NSException raise:NSInternalInconsistencyException format:@"attempt
to modify a previously executed operation"];
- bool didSwap;
int32_t val = flag ? 1 : 0;
- do {
- didSwap = OSAtomicCompareAndSwap32Barrier(_flags->_concurrent, val,
&(_flags->_concurrent));
- } while (false == didSwap);
+ atomic_store(&(_flags->_concurrent), val);
}
// semantics here as the same as for NSDate, if we consider the dates as
absolute time values
@@ -161,7 +155,7 @@
if ([self isExecuting] || [self isFinished])
[NSException raise:NSInternalInconsistencyException format:@"attempt
to start a previously executed operation"];
- OSAtomicIncrement32Barrier(&(_flags->_executing));
+ atomic_fetch_add(&(_flags->_executing), 1);
if ([self isConcurrent])
[FVThread detachNewThreadSelector:@selector(main) toTarget:self
withObject:nil];
@@ -173,7 +167,7 @@
{
// Make sure the queue releases its reference to this operation. This
always happens if it's cancelled by the queue, but someone else could call
-cancel, in which case this might be left in the queue's activeOperations bag.
[[self queue] finishedOperation:self];
- OSAtomicIncrement32Barrier(&(_flags->_finished));
+ atomic_fetch_add(&(_flags->_finished), 1);
}
@end
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPreviewer.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPreviewer.m 2023-11-03
22:43:04 UTC (rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPreviewer.m 2023-11-04
00:33:09 UTC (rev 28414)
@@ -92,7 +92,7 @@
return NO;
if (nil == theUTI || UTTypeEqual((CFStringRef)theUTI, kUTTypeData)) {
- NSAttributedString *string = [[[NSAttributedString alloc]
initWithURL:aURL documentAttributes:NULL] autorelease];
+ NSAttributedString *string = [[[NSAttributedString alloc]
initWithURL:aURL options:@{} documentAttributes:NULL error:NULL] autorelease];
return (string == nil);
}
else if (UTTypeConformsTo((CFStringRef)theUTI, kUTTypePDF) ||
UTTypeConformsTo((CFStringRef)theUTI, FVSTR("com.adobe.postscript"))) {
@@ -99,7 +99,7 @@
return NO;
}
else if ([FVTextIcon canInitWithURL:aURL withType:theUTI]) {
- NSAttributedString *string = [[[NSAttributedString alloc]
initWithURL:aURL documentAttributes:NULL] autorelease];
+ NSAttributedString *string = [[[NSAttributedString alloc]
initWithURL:aURL options:@{} documentAttributes:NULL error:NULL] autorelease];
return (string == nil);
}
@@ -344,7 +344,7 @@
else if (nil == theUTI || UTTypeEqual(theUTI, kUTTypeData)) {
theView = textView;
NSDictionary *attrs;
- NSAttributedString *string = [[NSAttributedString alloc]
initWithURL:representedURL documentAttributes:&attrs];
+ NSAttributedString *string = [[NSAttributedString alloc]
initWithURL:representedURL options:@{} documentAttributes:&attrs error:NULL];
if (string)
[self _loadAttributedString:string documentAttributes:attrs
inView:[textView documentView]];
else
@@ -381,7 +381,7 @@
else if ([FVTextIcon canInitWithURL:representedURL withType:(NSString
*)theUTI]) {
theView = textView;
NSDictionary *attrs;
- NSAttributedString *string = [[NSAttributedString alloc]
initWithURL:representedURL documentAttributes:&attrs];
+ NSAttributedString *string = [[NSAttributedString alloc]
initWithURL:representedURL options:@{} documentAttributes:&attrs error:NULL];
if (string)
[self _loadAttributedString:string documentAttributes:attrs
inView:[textView documentView]];
else
@@ -415,7 +415,7 @@
[spinner setStyle:NSProgressIndicatorSpinningStyle];
[spinner setUsesThreadedAnimation:YES];
[spinner setDisplayedWhenStopped:NO];
- [spinner setControlSize:NSRegularControlSize];
+ [spinner setControlSize:NSControlSizeRegular];
}
if ([spinner isDescendantOf:[mainFrame frameView]] == NO) {
[spinner removeFromSuperview];
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVScaledImageView.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVScaledImageView.m
2023-11-03 22:43:04 UTC (rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVScaledImageView.m
2023-11-04 00:33:09 UTC (rev 28414)
@@ -56,7 +56,7 @@
[ta setObject:[NSFont systemFontOfSize:[NSFont systemFontSize]]
forKey:NSFontAttributeName];
[ta setObject:[NSColor darkGrayColor]
forKey:NSForegroundColorAttributeName];
NSMutableParagraphStyle *ps = [[NSParagraphStyle defaultParagraphStyle]
mutableCopy];
- [ps setAlignment:NSCenterTextAlignment];
+ [ps setAlignment:NSTextAlignmentCenter];
[ta setObject:ps forKey:NSParagraphStyleAttributeName];
[ps release];
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVSlider.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVSlider.m 2023-11-03
22:43:04 UTC (rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVSlider.m 2023-11-04
00:33:09 UTC (rev 28414)
@@ -130,7 +130,7 @@
- (id)init
{
self = [super init];
- [self setControlSize:NSMiniControlSize];
+ [self setControlSize:NSControlSizeMini];
return self;
}
@@ -146,7 +146,7 @@
- (id)init
{
- self = [super initWithContentRect:NSMakeRect(0,0,50,10)
styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
+ self = [super initWithContentRect:NSMakeRect(0,0,50,10)
styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:YES];
if (self) {
[self setReleasedWhenClosed:NO];
[self setBackgroundColor:[NSColor clearColor]];
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.m 2023-11-03
22:43:04 UTC (rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.m 2023-11-04
00:33:09 UTC (rev 28414)
@@ -53,7 +53,7 @@
*/
if (type == nil || UTTypeEqual((CFStringRef)type, kUTTypeData)) {
// This is mainly useful to prove that the file cannot be opened; as
in the case of OmniGraffle files (see comment above), it returns YES.
- NSAttributedString *attributedString = [[NSAttributedString
allocWithZone:[self zone]] initWithURL:aURL documentAttributes:NULL];
+ NSAttributedString *attributedString = [[NSAttributedString
allocWithZone:[self zone]] initWithURL:aURL options:@{} documentAttributes:NULL
error:NULL];
BOOL canInit = (nil != attributedString);
[attributedString release];
return canInit;
@@ -117,7 +117,7 @@
Occasionally NSAttributedString might end up calling
NSHTMLReader/WebKit to load a file, which raises
an exception and crashes on 10.4. The workaround is to always load
on the main thread on 10.4.
*/
- attrString = [[NSMutableAttributedString alloc] initWithURL:_fileURL
documentAttributes:&documentAttributes];
+ attrString = [[NSMutableAttributedString alloc] initWithURL:_fileURL
options:@{} documentAttributes:&documentAttributes error:NULL];
}
// plain text failed and so did NSAttributedString, so display a mildly
unhelpful error message
@@ -144,7 +144,7 @@
// use a monospaced font for plain text
if (nil == documentAttributes || [[documentAttributes
objectForKey:NSDocumentTypeDocumentAttribute]
isEqualToString:NSPlainTextDocumentType]) {
- CTFontRef font =
CTFontCreateUIFontForLanguage(kCTFontUserFixedPitchFontType, 0, NULL);
+ CTFontRef font =
CTFontCreateUIFontForLanguage(kCTFontUIFontUserFixedPitch, 0, NULL);
CFAttributedStringSetAttribute(cfAttrString, CFRangeMake(0,
[attrString length]), kCTFontAttributeName, font);
CFRelease(font);
}
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVThread.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVThread.m 2023-11-03
22:43:04 UTC (rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVThread.m 2023-11-04
00:33:09 UTC (rev 28414)
@@ -38,7 +38,7 @@
#import "FVThread.h"
#import "FVUtilities.h"
-#import <libkern/OSAtomic.h>
+#import <stdatomic.h>
#import <pthread.h>
// lifted from CFInternal.h
@@ -91,7 +91,7 @@
static NSMutableArray *_threadPool = nil;
static pthread_mutex_t _lock = PTHREAD_MUTEX_INITIALIZER;
static int32_t _threadPoolCapacity = THREAD_POOL_MAX;
-static volatile int32_t _threadCount = 0;
+static _Atomic(int32_t) _threadCount = 0;
#define DEBUG_REAPER 0
@@ -136,7 +136,7 @@
pthread_mutex_unlock(&_lock);
if (nil == thread) {
thread = [_FVThread new];
- OSAtomicIncrement32Barrier(&_threadCount);
+ atomic_fetch_add(&_threadCount, 1);
}
return [thread autorelease];
}
@@ -155,7 +155,7 @@
+ (void)reapThreads
{
// !!! early return; recall that _threadCount != [_threadPool count] if
threads are working
- if (_threadCount <= THREAD_POOL_MIN)
+ if (atomic_load(&_threadCount) <= THREAD_POOL_MIN)
return;
pthread_mutex_lock(&_lock);
@@ -163,12 +163,12 @@
#if DEBUG_REAPER
FVLog(@"%d threads should fear the reaper", cnt);
#endif
- while (cnt-- && _threadCount > THREAD_POOL_MIN) {
+ while (cnt-- && atomic_load(&_threadCount) > THREAD_POOL_MIN) {
_FVThread *thread = [_threadPool objectAtIndex:cnt];
if (CFAbsoluteTimeGetCurrent() - [thread lastPerformTime] >
TIME_TO_DIE) {
[thread die];
[_threadPool removeObjectAtIndex:cnt];
- OSAtomicDecrement32Barrier(&_threadCount);
+ atomic_fetch_sub(&_threadCount, 1);
}
}
#if DEBUG_REAPER
@@ -179,7 +179,7 @@
+ (void)detachNewThreadSelector:(SEL)selector toTarget:(id)target
withObject:(id)argument;
{
- if (_threadPoolCapacity == _threadCount)
+ if (_threadPoolCapacity == atomic_load(&_threadCount))
[NSThread detachNewThreadSelector:selector toTarget:target
withObject:argument];
else
[[self thread] performSelector:selector withTarget:target
argument:argument];
@@ -193,8 +193,8 @@
if (self) {
// for debugging
- static volatile int32_t threadIndex = 0;
- _threadIndex = OSAtomicIncrement32Barrier(&threadIndex);
+ static _Atomic(int32_t) threadIndex = 0;
+ atomic_fetch_add(&threadIndex, 1);
_lastPerformTime = CFAbsoluteTimeGetCurrent();
_flags = 0;
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.m 2023-11-03
22:43:04 UTC (rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.m 2023-11-04
00:33:09 UTC (rev 28414)
@@ -168,7 +168,7 @@
{
NSRect rect = NSZeroRect;
rect.size = size;
- NSWindow *window = [[NSWindow alloc] initWithContentRect:rect
styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
+ NSWindow *window = [[NSWindow alloc] initWithContentRect:rect
styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:NO];
[window autorelease];
return [NSGraphicsContext graphicsContextWithWindow:window];
}
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/_FVMappedDataProvider.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/_FVMappedDataProvider.m
2023-11-03 22:43:04 UTC (rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/_FVMappedDataProvider.m
2023-11-04 00:33:09 UTC (rev 28414)
@@ -41,9 +41,8 @@
#import <pthread.h>
#import <sys/mman.h>
#import <sys/stat.h>
-#import <libkern/OSAtomic.h>
+#import <stdatomic.h>
-
typedef struct _FVMappedRegion {
NSZone *zone;
char *path;
@@ -51,7 +50,7 @@
off_t length;
} FVMappedRegion;
-static volatile int32_t _mappedDataSizeKB = 0;
+static _Atomic(off_t) _mappedDataSizeKB = 0;
#define MAX_MAPPED_SIZE_KB 400000
// This is intentionally low, since I don't know what the limit is, and sysctl
doesn't say. The max number of file descriptors is ~255 per process, but I can
actually mmap ~28,000 files on 10.5.4. We should never see even this many in
practice, though.
@@ -82,7 +81,7 @@
+ (BOOL)maxSizeExceeded
{
- return _mappedDataSizeKB > MAX_MAPPED_SIZE_KB ||
CFDictionaryGetCount(_dataProviders) >= MAX_MAPPED_PROVIDER_COUNT;
+ return atomic_load(&_mappedDataSizeKB) > MAX_MAPPED_SIZE_KB ||
CFDictionaryGetCount(_dataProviders) >= MAX_MAPPED_PROVIDER_COUNT;
}
+ (unsigned char)maxProviderCount;
@@ -125,11 +124,8 @@
mapInfo->mapregion = NULL;
}
else {
- bool swap;
- do {
- int32_t newSize = _mappedDataSizeKB + (mapInfo->length) /
1024;
- swap = OSAtomicCompareAndSwap32Barrier(_mappedDataSizeKB,
newSize, &_mappedDataSizeKB);
- } while (false == swap);
+ off_t newSize = atomic_load(&_mappedDataSizeKB) +
(mapInfo->length) / 1024;
+ atomic_store(&_mappedDataSizeKB, newSize);
}
pInfo->_provider = CGDataProviderCreateDirect(mapInfo,
mapInfo->length, &_FVMappedDataProviderDirectCallBacks);
}
@@ -174,11 +170,8 @@
FVMappedRegion *mapInfo = info;
NSZoneFree(mapInfo->zone, mapInfo->path);
if (mapInfo->mapregion) munmap(mapInfo->mapregion, mapInfo->length);
- bool swap;
- do {
- int32_t newSize = _mappedDataSizeKB - (mapInfo->length) / 1024;
- swap = OSAtomicCompareAndSwap32Barrier(_mappedDataSizeKB, newSize,
&_mappedDataSizeKB);
- } while (false == swap);
+ off_t newSize = atomic_load(&_mappedDataSizeKB) - (mapInfo->length) / 1024;
+ atomic_store(&_mappedDataSizeKB, newSize);
NSZoneFree(mapInfo->zone, info);
}
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/_FVPreviewerWindow.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/_FVPreviewerWindow.m
2023-11-03 22:43:04 UTC (rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/_FVPreviewerWindow.m
2023-11-04 00:33:09 UTC (rev 28414)
@@ -48,11 +48,8 @@
if (CGRectContainsPoint(NSRectToCGRect([self frame]),
CGEventGetUnflippedLocation(event))) {
- // See header for GetDblTime. Getting kCGMouseEventClickState didn't
work.
- NXEventHandle handle = NXOpenEventStatus();
- double clickTime = NXClickTime(handle);
- NXCloseEventStatus(handle);
-
+ NSTimeInterval clickTime = [NSEvent doubleClickInterval];
+
NSTimeInterval currentTime = [NSDate timeIntervalSinceReferenceDate];
/*
If the first two clicks represent a double-click, treat it as a
request to open
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/fv_zone.cpp
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/fv_zone.cpp 2023-11-03
22:43:04 UTC (rev 28413)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/fv_zone.cpp 2023-11-04
00:33:09 UTC (rev 28414)
@@ -39,7 +39,6 @@
*/
#import "fv_zone.h"
-#import <libkern/OSAtomic.h>
#import <malloc/malloc.h>
#import <mach/mach.h>
#import <mach/mach_vm.h>
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