Revision: 13858
          http://sourceforge.net/p/skim-app/code/13858
Author:   hofman
Date:     2023-12-08 17:06:01 +0000 (Fri, 08 Dec 2023)
Log Message:
-----------
Use ARC for quicklook generator

Modified Paths:
--------------
    trunk/QuickLook-Skim/GeneratePreviewForURL.m
    trunk/QuickLook-Skim/GenerateThumbnailForURL.m
    trunk/QuickLook-Skim/QuickLook-Skim.xcodeproj/project.pbxproj
    trunk/QuickLook-Skim/SKQLConverter.m

Modified: trunk/QuickLook-Skim/GeneratePreviewForURL.m
===================================================================
--- trunk/QuickLook-Skim/GeneratePreviewForURL.m        2023-12-08 15:37:30 UTC 
(rev 13857)
+++ trunk/QuickLook-Skim/GeneratePreviewForURL.m        2023-12-08 17:06:01 UTC 
(rev 13858)
@@ -46,7 +46,7 @@
     NSMutableDictionary *imgProps;
     
     for (NSString *imageName in imageNames) {
-        NSURL *imgURL = (NSURL *)CFBundleCopyResourceURL(bundle, 
(CFStringRef)imageName, CFSTR("png"), NULL);
+        NSURL *imgURL = (NSURL 
*)CFBridgingRelease(CFBundleCopyResourceURL(bundle, (__bridge 
CFStringRef)imageName, CFSTR("png"), NULL));
         if (imgURL) {
             NSData *imgData = [NSData dataWithContentsOfURL:imgURL];
             if (imgData) {
@@ -53,9 +53,7 @@
                 imgProps = [[NSMutableDictionary alloc] init];
                 [imgProps setObject:imgData forKey:(NSString 
*)kQLPreviewPropertyAttachmentDataKey];
                 [attachments setObject:imgProps forKey:[imageName 
stringByAppendingPathExtension:@"png"]];
-                [imgProps release];
             }
-            [imgURL release];
         }
     }
     return attachments;
@@ -69,63 +67,63 @@
 
 OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef 
preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options)
 {
-    NSAutoreleasePool *pool = [NSAutoreleasePool new];
     OSStatus err = 2;
     
-    if (UTTypeEqual(CFSTR("net.sourceforge.skim-app.pdfd"), contentTypeUTI)) {
+    @autoreleasepool{
         
-        NSString *pdfFile = SKQLPDFPathForPDFBundleURL((NSURL *)url);
-        if (pdfFile) {
-            NSData *data = [NSData dataWithContentsOfFile:pdfFile];
-            if (data) {
-                QLPreviewRequestSetDataRepresentation(preview, 
(CFDataRef)data, kUTTypePDF, NULL);
-                err = noErr;
+        if (UTTypeEqual(CFSTR("net.sourceforge.skim-app.pdfd"), 
contentTypeUTI)) {
+            
+            NSString *pdfFile = SKQLPDFPathForPDFBundleURL((__bridge NSURL 
*)url);
+            if (pdfFile) {
+                NSData *data = [NSData dataWithContentsOfFile:pdfFile];
+                if (data) {
+                    QLPreviewRequestSetDataRepresentation(preview, (__bridge 
CFDataRef)data, kUTTypePDF, NULL);
+                    err = noErr;
+                }
             }
-        }
-        
-    } else if (UTTypeEqual(CFSTR("com.adobe.postscript"), contentTypeUTI)) {
-        
-        if (floor(NSAppKitVersionNumber) <= 2299.0) {
-            bool converted = false;
-            CGPSConverterCallbacks converterCallbacks = { 0, NULL, NULL, NULL, 
NULL, NULL, NULL, NULL };
-            CGPSConverterRef converter = CGPSConverterCreate(NULL, 
&converterCallbacks, NULL);
-            CGDataProviderRef provider = CGDataProviderCreateWithURL(url);
-            CFMutableDataRef data = CFDataCreateMutable(NULL, 0);
-            CGDataConsumerRef consumer = CGDataConsumerCreateWithCFData(data);
-            if (provider != NULL && consumer != NULL)
-                converted = CGPSConverterConvert(converter, provider, 
consumer, NULL);
-            CGDataProviderRelease(provider);
-            CGDataConsumerRelease(consumer);
-            CFRelease(converter);
-            if (converted) {
-                QLPreviewRequestSetDataRepresentation(preview, data, 
kUTTypePDF, NULL);
-                err = noErr;
+            
+        } else if (UTTypeEqual(CFSTR("com.adobe.postscript"), contentTypeUTI)) 
{
+            
+            if (floor(NSAppKitVersionNumber) <= 2299.0) {
+                bool converted = false;
+                CGPSConverterCallbacks converterCallbacks = { 0, NULL, NULL, 
NULL, NULL, NULL, NULL, NULL };
+                CGPSConverterRef converter = CGPSConverterCreate(NULL, 
&converterCallbacks, NULL);
+                CGDataProviderRef provider = CGDataProviderCreateWithURL(url);
+                CFMutableDataRef data = CFDataCreateMutable(NULL, 0);
+                CGDataConsumerRef consumer = 
CGDataConsumerCreateWithCFData(data);
+                if (provider != NULL && consumer != NULL)
+                    converted = CGPSConverterConvert(converter, provider, 
consumer, NULL);
+                CGDataProviderRelease(provider);
+                CGDataConsumerRelease(consumer);
+                CFRelease(converter);
+                if (converted) {
+                    QLPreviewRequestSetDataRepresentation(preview, data, 
kUTTypePDF, NULL);
+                    err = noErr;
+                }
+                if (data) CFRelease(data);
             }
-            if (data) CFRelease(data);
-        }
-        
-    } else if (UTTypeEqual(CFSTR("net.sourceforge.skim-app.skimnotes"), 
contentTypeUTI)) {
-        
-        NSData *data = [[NSData alloc] initWithContentsOfURL:(NSURL *)url 
options:NSUncachedRead error:NULL];
-        if (data) {
-            NSArray *notes = [SKQLConverter notesWithData:data];
-            NSString *htmlString = [SKQLConverter htmlStringWithNotes:notes];
-            [data release];
-            if ((data = [htmlString dataUsingEncoding:NSUTF8StringEncoding])) {
-                NSSet *types = [NSSet setWithArray:[notes 
valueForKey:@"type"]];
-                NSDictionary *props = [NSDictionary 
dictionaryWithObjectsAndKeys:
-                                            @"UTF-8", (NSString 
*)kQLPreviewPropertyTextEncodingNameKey,
-                                            @"text/html", (NSString 
*)kQLPreviewPropertyMIMETypeKey,
-                                            imageAttachments(types, preview), 
(NSString *)kQLPreviewPropertyAttachmentsKey, nil];
-                QLPreviewRequestSetDataRepresentation(preview, 
(CFDataRef)data, kUTTypeHTML, (CFDictionaryRef)props);
-                err = noErr;
+            
+        } else if (UTTypeEqual(CFSTR("net.sourceforge.skim-app.skimnotes"), 
contentTypeUTI)) {
+            
+            NSData *data = [[NSData alloc] initWithContentsOfURL:(__bridge 
NSURL *)url options:NSUncachedRead error:NULL];
+            if (data) {
+                NSArray *notes = [SKQLConverter notesWithData:data];
+                NSString *htmlString = [SKQLConverter 
htmlStringWithNotes:notes];
+                if ((data = [htmlString 
dataUsingEncoding:NSUTF8StringEncoding])) {
+                    NSSet *types = [NSSet setWithArray:[notes 
valueForKey:@"type"]];
+                    NSDictionary *props = [NSDictionary 
dictionaryWithObjectsAndKeys:
+                                                @"UTF-8", (__bridge NSString 
*)kQLPreviewPropertyTextEncodingNameKey,
+                                                @"text/html", (__bridge 
NSString *)kQLPreviewPropertyMIMETypeKey,
+                                                imageAttachments(types, 
preview), (NSString *)kQLPreviewPropertyAttachmentsKey, nil];
+                    QLPreviewRequestSetDataRepresentation(preview, (__bridge 
CFDataRef)data, kUTTypeHTML, (__bridge CFDictionaryRef)props);
+                    err = noErr;
+                }
             }
+            
         }
         
     }
     
-    [pool release];
-    
     return err;
 }
 

Modified: trunk/QuickLook-Skim/GenerateThumbnailForURL.m
===================================================================
--- trunk/QuickLook-Skim/GenerateThumbnailForURL.m      2023-12-08 15:37:30 UTC 
(rev 13857)
+++ trunk/QuickLook-Skim/GenerateThumbnailForURL.m      2023-12-08 17:06:01 UTC 
(rev 13858)
@@ -53,12 +53,10 @@
     NSRect pageRect = { NSZeroPoint, _paperSize };
     NSRectFillUsingOperation(pageRect, NSCompositingOperationSourceOver);
     
-    NSURL *iconURL = (NSURL 
*)CFBundleCopyResourceURL(QLThumbnailRequestGetGeneratorBundle(thumbnail), 
CFSTR("Skim"), CFSTR("icns"), NULL);
+    NSURL *iconURL = (NSURL 
*)CFBridgingRelease(CFBundleCopyResourceURL(QLThumbnailRequestGetGeneratorBundle(thumbnail),
 CFSTR("Skim"), CFSTR("icns"), NULL));
     NSImage *appIcon = [[NSImage alloc] initWithContentsOfFile:[iconURL path]];
-    [iconURL release];
     
     [appIcon drawInRect:_iconRect fromRect:NSZeroRect 
operation:NSCompositingOperationSourceOver fraction:0.3];
-    [appIcon release];    
 }
 
 // creates a new NSTextStorage/NSLayoutManager/NSTextContainer system suitable 
for drawing in a thread
@@ -72,10 +70,6 @@
     // don't let the layout manager use its threaded layout (see header)
     [lm setBackgroundLayoutEnabled:NO];
     [textStorage addLayoutManager:lm];
-    // retained by layout manager
-    [tc release];
-    // retained by text storage
-    [lm release];
     // see header; the CircleView example sets it to NO
     //[lm setUsesScreenFonts:YES];
 
@@ -118,7 +112,6 @@
         [lm drawGlyphsForGlyphRange:glyphRange atPoint:usedRect.origin];
     }        
     CGContextRestoreGState(ctxt);
-    [textStorage release];    
 }
 
 /* 
-----------------------------------------------------------------------------
@@ -129,56 +122,16 @@
 
 OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef 
thumbnail, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options, 
CGSize maximumSize)
 {
-    NSAutoreleasePool *pool = [NSAutoreleasePool new];
-    bool didGenerate = false;
-    
-    if (UTTypeEqual(CFSTR("net.sourceforge.skim-app.pdfd"), contentTypeUTI)) {
+    @autoreleasepool{
+        bool didGenerate = false;
         
-        NSString *pdfFile = SKQLPDFPathForPDFBundleURL((NSURL *)url);
-        
-        if (pdfFile) {
-            // sadly, we can't use the system's QL generator from inside 
quicklookd, so we don't get the fancy binder on the left edge
-            CGPDFDocumentRef pdfDoc = 
CGPDFDocumentCreateWithURL((CFURLRef)[NSURL fileURLWithPath:pdfFile]);
-            CGPDFPageRef pdfPage = NULL;
-            if (pdfDoc && CGPDFDocumentGetNumberOfPages(pdfDoc) > 0)
-                pdfPage = CGPDFDocumentGetPage(pdfDoc, 1);
+        if (UTTypeEqual(CFSTR("net.sourceforge.skim-app.pdfd"), 
contentTypeUTI)) {
             
-            if (pdfPage) {
-                CGRect pageRect = CGPDFPageGetBoxRect(pdfPage, kCGPDFCropBox);
-                CGRect thumbRect = {{0.0, 0.0}, {CGRectGetWidth(pageRect), 
CGRectGetHeight(pageRect)}};
-                CGFloat color[4] = {1.0, 1.0, 1.0, 1.0};
-                CGContextRef ctxt = QLThumbnailRequestCreateContext(thumbnail, 
thumbRect.size, FALSE, NULL);
-                CGAffineTransform t = CGPDFPageGetDrawingTransform(pdfPage, 
kCGPDFCropBox, thumbRect, 0, true);
-                CGContextConcatCTM(ctxt, t);
-                CGContextClipToRect(ctxt, pageRect);
-                CGContextSetFillColor(ctxt, color);
-                CGContextFillRect(ctxt, pageRect);
-                CGContextDrawPDFPage(ctxt, pdfPage);
-                QLThumbnailRequestFlushContext(thumbnail, ctxt);
-                CGContextRelease(ctxt);
-                didGenerate = true;
-            }
-            CGPDFDocumentRelease(pdfDoc);
-        }
-        
-    } else if (UTTypeEqual(CFSTR("com.adobe.postscript"), contentTypeUTI)) {
-        
-        if (floor(NSAppKitVersionNumber) <= 2299.0) {
-            bool converted = false;
-            CGPSConverterCallbacks converterCallbacks = { 0, NULL, NULL, NULL, 
NULL, NULL, NULL, NULL };
-            CGPSConverterRef converter = CGPSConverterCreate(NULL, 
&converterCallbacks, NULL);
-            CGDataProviderRef provider = CGDataProviderCreateWithURL(url);
-            CFMutableDataRef pdfData = CFDataCreateMutable(NULL, 0);
-            CGDataConsumerRef consumer = 
CGDataConsumerCreateWithCFData(pdfData);
-            if (provider != NULL && consumer != NULL)
-                converted = CGPSConverterConvert(converter, provider, 
consumer, NULL);
-            CGDataProviderRelease(provider);
-            CGDataConsumerRelease(consumer);
-            CFRelease(converter);
-            if (converted) {
+            NSString *pdfFile = SKQLPDFPathForPDFBundleURL((__bridge NSURL 
*)url);
+            
+            if (pdfFile) {
                 // sadly, we can't use the system's QL generator from inside 
quicklookd, so we don't get the fancy binder on the left edge
-                provider = CGDataProviderCreateWithCFData(pdfData);
-                CGPDFDocumentRef pdfDoc = 
CGPDFDocumentCreateWithProvider(provider);
+                CGPDFDocumentRef pdfDoc = 
CGPDFDocumentCreateWithURL((CFURLRef)[NSURL fileURLWithPath:pdfFile]);
                 CGPDFPageRef pdfPage = NULL;
                 if (pdfDoc && CGPDFDocumentGetNumberOfPages(pdfDoc) > 0)
                     pdfPage = CGPDFDocumentGetPage(pdfDoc, 1);
@@ -199,63 +152,101 @@
                     didGenerate = true;
                 }
                 CGPDFDocumentRelease(pdfDoc);
+            }
+            
+        } else if (UTTypeEqual(CFSTR("com.adobe.postscript"), contentTypeUTI)) 
{
+            
+            if (floor(NSAppKitVersionNumber) <= 2299.0) {
+                bool converted = false;
+                CGPSConverterCallbacks converterCallbacks = { 0, NULL, NULL, 
NULL, NULL, NULL, NULL, NULL };
+                CGPSConverterRef converter = CGPSConverterCreate(NULL, 
&converterCallbacks, NULL);
+                CGDataProviderRef provider = CGDataProviderCreateWithURL(url);
+                CFMutableDataRef pdfData = CFDataCreateMutable(NULL, 0);
+                CGDataConsumerRef consumer = 
CGDataConsumerCreateWithCFData(pdfData);
+                if (provider != NULL && consumer != NULL)
+                    converted = CGPSConverterConvert(converter, provider, 
consumer, NULL);
                 CGDataProviderRelease(provider);
+                CGDataConsumerRelease(consumer);
+                CFRelease(converter);
+                if (converted) {
+                    // sadly, we can't use the system's QL generator from 
inside quicklookd, so we don't get the fancy binder on the left edge
+                    provider = CGDataProviderCreateWithCFData(pdfData);
+                    CGPDFDocumentRef pdfDoc = 
CGPDFDocumentCreateWithProvider(provider);
+                    CGPDFPageRef pdfPage = NULL;
+                    if (pdfDoc && CGPDFDocumentGetNumberOfPages(pdfDoc) > 0)
+                        pdfPage = CGPDFDocumentGetPage(pdfDoc, 1);
+                    
+                    if (pdfPage) {
+                        CGRect pageRect = CGPDFPageGetBoxRect(pdfPage, 
kCGPDFCropBox);
+                        CGRect thumbRect = {{0.0, 0.0}, 
{CGRectGetWidth(pageRect), CGRectGetHeight(pageRect)}};
+                        CGFloat color[4] = {1.0, 1.0, 1.0, 1.0};
+                        CGContextRef ctxt = 
QLThumbnailRequestCreateContext(thumbnail, thumbRect.size, FALSE, NULL);
+                        CGAffineTransform t = 
CGPDFPageGetDrawingTransform(pdfPage, kCGPDFCropBox, thumbRect, 0, true);
+                        CGContextConcatCTM(ctxt, t);
+                        CGContextClipToRect(ctxt, pageRect);
+                        CGContextSetFillColor(ctxt, color);
+                        CGContextFillRect(ctxt, pageRect);
+                        CGContextDrawPDFPage(ctxt, pdfPage);
+                        QLThumbnailRequestFlushContext(thumbnail, ctxt);
+                        CGContextRelease(ctxt);
+                        didGenerate = true;
+                    }
+                    CGPDFDocumentRelease(pdfDoc);
+                    CGDataProviderRelease(provider);
+                }
+                if (pdfData) CFRelease(pdfData);
             }
-            if (pdfData) CFRelease(pdfData);
+            
+        } else if (UTTypeEqual(CFSTR("net.sourceforge.skim-app.skimnotes"), 
contentTypeUTI)) {
+            
+            NSData *data = [[NSData alloc] initWithContentsOfURL:(__bridge 
NSURL *)url options:NSUncachedRead error:NULL];
+            
+            if (data) {
+                NSArray *notes = [SKQLConverter notesWithData:data];
+                NSAttributedString *attrString = [SKQLConverter 
attributedStringWithNotes:notes 
bundle:QLThumbnailRequestGetGeneratorBundle(thumbnail)];
+                
+                if (attrString) {
+                    CGContextRef ctxt = 
QLThumbnailRequestCreateContext(thumbnail, *(CGSize *)&_paperSize, FALSE, NULL);
+                    NSGraphicsContext *nsContext = [NSGraphicsContext 
graphicsContextWithGraphicsPort:ctxt flipped:YES];
+                    [NSGraphicsContext saveGraphicsState];
+                    [NSGraphicsContext setCurrentContext:nsContext];
+                    
+                    
drawBackgroundAndApplicationIconInCurrentContext(thumbnail);
+                    drawAttributedStringInCurrentContext(attrString);
+                    
+                    QLThumbnailRequestFlushContext(thumbnail, ctxt);
+                    CGContextRelease(ctxt);
+                    
+                    [NSGraphicsContext restoreGraphicsState];
+                    didGenerate = true;
+                }
+            }
+            
         }
         
-    } else if (UTTypeEqual(CFSTR("net.sourceforge.skim-app.skimnotes"), 
contentTypeUTI)) {
-        
-        NSData *data = [[NSData alloc] initWithContentsOfURL:(NSURL *)url 
options:NSUncachedRead error:NULL];
-        
-        if (data) {
-            NSArray *notes = [SKQLConverter notesWithData:data];
-            NSAttributedString *attrString = [SKQLConverter 
attributedStringWithNotes:notes 
bundle:QLThumbnailRequestGetGeneratorBundle(thumbnail)];
-            [data release];
+        /* fallback case: draw the file icon using Icon Services */
+        if (false == didGenerate) {
             
-            if (attrString) {
-                CGContextRef ctxt = QLThumbnailRequestCreateContext(thumbnail, 
*(CGSize *)&_paperSize, FALSE, NULL);
-                NSGraphicsContext *nsContext = [NSGraphicsContext 
graphicsContextWithGraphicsPort:ctxt flipped:YES];
+            NSString *path = (NSString *)CFBridgingRelease(CFURLCopyPath(url));
+            NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:path];
+            
+            if (icon) {
+                CGFloat side = MIN(maximumSize.width, maximumSize.height);
+                NSRect rect = NSMakeRect(0.0, 0.0, side, side);
+                CGContextRef ctxt = QLThumbnailRequestCreateContext(thumbnail, 
rect.size, FALSE, NULL);
+                NSGraphicsContext *nsContext = [NSGraphicsContext 
graphicsContextWithGraphicsPort:ctxt flipped:NO];
                 [NSGraphicsContext saveGraphicsState];
                 [NSGraphicsContext setCurrentContext:nsContext];
                 
-                drawBackgroundAndApplicationIconInCurrentContext(thumbnail);
-                drawAttributedStringInCurrentContext(attrString);
+                [icon drawInRect:rect];
                 
                 QLThumbnailRequestFlushContext(thumbnail, ctxt);
                 CGContextRelease(ctxt);
                 
-                [NSGraphicsContext restoreGraphicsState];    
-                didGenerate = true;
+                [NSGraphicsContext restoreGraphicsState];
             }
         }
-        
     }
-    
-    /* fallback case: draw the file icon using Icon Services */
-    if (false == didGenerate) {
-        
-        CFStringRef path = CFURLCopyPath(url);
-        NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:(NSString 
*)path];
-        CFRelease(path);
-        
-        if (icon) {
-            CGFloat side = MIN(maximumSize.width, maximumSize.height);
-            NSRect rect = NSMakeRect(0.0, 0.0, side, side);
-            CGContextRef ctxt = QLThumbnailRequestCreateContext(thumbnail, 
rect.size, FALSE, NULL);
-            NSGraphicsContext *nsContext = [NSGraphicsContext 
graphicsContextWithGraphicsPort:ctxt flipped:NO];
-            [NSGraphicsContext saveGraphicsState];
-            [NSGraphicsContext setCurrentContext:nsContext];
-            
-            [icon drawInRect:rect];
-            
-            QLThumbnailRequestFlushContext(thumbnail, ctxt);
-            CGContextRelease(ctxt);
-            
-            [NSGraphicsContext restoreGraphicsState];
-        }
-    }
-    [pool release];
     return noErr;
 }
 

Modified: trunk/QuickLook-Skim/QuickLook-Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/QuickLook-Skim/QuickLook-Skim.xcodeproj/project.pbxproj       
2023-12-08 15:37:30 UTC (rev 13857)
+++ trunk/QuickLook-Skim/QuickLook-Skim.xcodeproj/project.pbxproj       
2023-12-08 17:06:01 UTC (rev 13858)
@@ -306,6 +306,7 @@
                2CA3261F0896AD4900168862 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CLANG_ENABLE_OBJC_ARC = YES;
                                INFOPLIST_FILE = Info.plist;
                                INSTALL_PATH = /Library/QuickLook;
                                PRODUCT_BUNDLE_IDENTIFIER = 
"net.sourceforge.skim-app.quicklookgenerator";
@@ -317,6 +318,7 @@
                2CA326200896AD4900168862 /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CLANG_ENABLE_OBJC_ARC = YES;
                                INFOPLIST_FILE = Info.plist;
                                INSTALL_PATH = /Library/QuickLook;
                                PRODUCT_BUNDLE_IDENTIFIER = 
"net.sourceforge.skim-app.quicklookgenerator";

Modified: trunk/QuickLook-Skim/SKQLConverter.m
===================================================================
--- trunk/QuickLook-Skim/SKQLConverter.m        2023-12-08 15:37:30 UTC (rev 
13857)
+++ trunk/QuickLook-Skim/SKQLConverter.m        2023-12-08 17:06:01 UTC (rev 
13858)
@@ -63,19 +63,16 @@
     NSFileWrapper *wrapper = [imageWrappers objectForKey:type];
     
     if (wrapper == nil) {
-        CFURLRef imgURL = CFBundleCopyResourceURL(bundle, (CFStringRef)type, 
CFSTR("png"), NULL);
+        NSURL *imgURL = (NSURL 
*)CFBridgingRelease(CFBundleCopyResourceURL(bundle, (CFStringRef)type, 
CFSTR("png"), NULL));
         if (imageWrappers == nil)
             imageWrappers = [[NSMutableDictionary alloc] init];
-        wrapper = [[NSFileWrapper alloc] initWithURL:(NSURL *)imgURL options:0 
error:NULL];
+        wrapper = [[NSFileWrapper alloc] initWithURL:imgURL options:0 
error:NULL];
         [wrapper setPreferredFilename:[type 
stringByAppendingPathExtension:@"png"]];
         [imageWrappers setObject:wrapper forKey:type];
-        [wrapper release];
-        if (imgURL) CFRelease(imgURL);
     }
     
     NSTextAttachment *attachment = [[NSTextAttachment alloc] 
initWithFileWrapper:wrapper];
     NSAttributedString *attrString = [NSAttributedString 
attributedStringWithAttachment:attachment];
-    [attachment release];
     
     return attrString;
 }
@@ -110,13 +107,10 @@
 {
     unichar *ptr, *begin, *end;
     NSMutableString *result;
-    NSString *string;
     NSInteger length;
     
 #define APPEND_PREVIOUS() \
-    string = [[NSString alloc] initWithCharacters:begin length:(ptr - begin)]; 
\
-    [result appendString:string]; \
-    [string release]; \
+    [result appendString:[[NSString alloc] initWithCharacters:begin 
length:(ptr - begin)]]; \
     begin = ptr + 1;
     
     length = [htmlString length];
@@ -183,7 +177,7 @@
 
 + (NSAttributedString *)attributedStringWithNotes:(NSArray *)notes 
bundle:(CFBundleRef)bundle;
 {
-    NSMutableAttributedString *attrString = [[[NSMutableAttributedString 
alloc] init] autorelease];
+    NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] 
init];
     NSFont *font = [NSFont userFontOfSize:_fontSize];
     NSFont *noteFont = [NSFont fontWithName:_noteFontName size:_fontSize];
     NSFont *noteTextFont = [NSFont fontWithName:_noteFontName 
size:_smallFontSize];
@@ -190,13 +184,13 @@
     NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:font, 
NSFontAttributeName, nil];
     NSDictionary *noteAttrs = [NSDictionary 
dictionaryWithObjectsAndKeys:noteFont, NSFontAttributeName, [NSParagraphStyle 
defaultParagraphStyle], NSParagraphStyleAttributeName, nil];
     NSDictionary *noteTextAttrs = [NSDictionary 
dictionaryWithObjectsAndKeys:noteTextFont, NSFontAttributeName, 
[NSParagraphStyle defaultParagraphStyle], NSParagraphStyleAttributeName, nil];
-    NSMutableParagraphStyle *noteParStyle = [[[NSParagraphStyle 
defaultParagraphStyle] mutableCopy] autorelease];
+    NSMutableParagraphStyle *noteParStyle = [[NSParagraphStyle 
defaultParagraphStyle] mutableCopy];
     
     [noteParStyle setFirstLineHeadIndent:_noteIndent];
     [noteParStyle setHeadIndent:_noteIndent];
     
     if (notes) {
-        NSSortDescriptor *sortDescriptor = [[[NSSortDescriptor alloc] 
initWithKey:@"pageIndex" ascending:YES] autorelease];
+        NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] 
initWithKey:@"pageIndex" ascending:YES];
         NSEnumerator *noteEnum = [[notes sortedArrayUsingDescriptors:[NSArray 
arrayWithObject:sortDescriptor]] objectEnumerator];
         NSDictionary *note;
         while (note = [noteEnum nextObject]) {
@@ -208,20 +202,20 @@
             NSInteger start;
             
             if ([text isKindOfClass:[NSData class]])
-                text = [[[NSAttributedString alloc] initWithData:(NSData 
*)text options:[NSDictionary dictionary] documentAttributes:NULL error:NULL] 
autorelease];
+                text = [[NSAttributedString alloc] initWithData:(NSData *)text 
options:[NSDictionary dictionary] documentAttributes:NULL error:NULL];
             if ([color isKindOfClass:[NSArray class]])
                 color = colorFromArray((NSArray *)color);
             
             [attrString appendAttributedString:imageAttachmentForType(type, 
bundle)];
             [attrString addAttribute:NSBackgroundColorAttributeName 
value:color range:NSMakeRange([attrString length] - 1, 1)];
-            [attrString appendAttributedString:[[[NSAttributedString alloc] 
initWithString:[NSString stringWithFormat:@"%@ (page %ld)\n", type, 
(long)(pageIndex+1)] attributes:attrs] autorelease]];
+            [attrString appendAttributedString:[[NSAttributedString alloc] 
initWithString:[NSString stringWithFormat:@"%@ (page %ld)\n", type, 
(long)(pageIndex+1)] attributes:attrs]];
             start = [attrString length];
-            [attrString appendAttributedString:[[[NSAttributedString alloc] 
initWithString:contents attributes:noteAttrs] autorelease]];
+            [attrString appendAttributedString:[[NSAttributedString alloc] 
initWithString:contents attributes:noteAttrs]];
             if (text) {
-                [attrString appendAttributedString:[[[NSAttributedString 
alloc] initWithString:@"\n"] autorelease]];
-                [attrString appendAttributedString:[[[NSAttributedString 
alloc] initWithString:[text string] attributes:noteTextAttrs] autorelease]];
+                [attrString appendAttributedString:[[NSAttributedString alloc] 
initWithString:@"\n"]];
+                [attrString appendAttributedString:[[NSAttributedString alloc] 
initWithString:[text string] attributes:noteTextAttrs]];
             }
-            [attrString appendAttributedString:[[[NSAttributedString alloc] 
initWithString:@"\n"] autorelease]];
+            [attrString appendAttributedString:[[NSAttributedString alloc] 
initWithString:@"\n"]];
             [attrString addAttribute:NSParagraphStyleAttributeName 
value:noteParStyle range:NSMakeRange(start, [attrString length] - start)];
         }
         [attrString fixAttributesInRange:NSMakeRange(0, [attrString length])];
@@ -240,7 +234,7 @@
     [htmlString appendString:@"</style></head><body><dl>"];
     
     if (notes) {
-        NSSortDescriptor *sortDescriptor = [[[NSSortDescriptor alloc] 
initWithKey:@"pageIndex" ascending:YES] autorelease];
+        NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] 
initWithKey:@"pageIndex" ascending:YES];
         NSEnumerator *noteEnum = [[notes sortedArrayUsingDescriptors:[NSArray 
arrayWithObject:sortDescriptor]] objectEnumerator];
         NSDictionary *note;
         while (note = [noteEnum nextObject]) {
@@ -251,7 +245,7 @@
             NSUInteger pageIndex = [[note objectForKey:@"pageIndex"] 
unsignedIntegerValue];
             
             if ([text isKindOfClass:[NSData class]])
-                text = [[[NSAttributedString alloc] initWithData:(NSData 
*)text options:[NSDictionary dictionary] documentAttributes:NULL error:NULL] 
autorelease];
+                text = [[NSAttributedString alloc] initWithData:(NSData *)text 
options:[NSDictionary dictionary] documentAttributes:NULL error:NULL];
             if ([color isKindOfClass:[NSArray class]])
                 color = colorFromArray((NSArray *)color);
             

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



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to