Revision: 6718
          http://skim-app.svn.sourceforge.net/skim-app/?rev=6718&view=rev
Author:   hofman
Date:     2010-08-19 17:51:02 +0000 (Thu, 19 Aug 2010)

Log Message:
-----------
workaround for leak of initial border of annotations in PDFKit version 2.5 and 
2.5.1, send it an extra release when we use this PDFKit version

Modified Paths:
--------------
    trunk/PDFAnnotationCircle_SKExtensions.m
    trunk/PDFAnnotationInk_SKExtensions.m
    trunk/PDFAnnotationSquare_SKExtensions.m
    trunk/PDFAnnotation_SKExtensions.h
    trunk/PDFAnnotation_SKExtensions.m
    trunk/SKApplicationController.m

Modified: trunk/PDFAnnotationCircle_SKExtensions.m
===================================================================
--- trunk/PDFAnnotationCircle_SKExtensions.m    2010-08-19 17:09:41 UTC (rev 
6717)
+++ trunk/PDFAnnotationCircle_SKExtensions.m    2010-08-19 17:51:02 UTC (rev 
6718)
@@ -50,6 +50,8 @@
 
 - (id)initSkimNoteWithBounds:(NSRect)bounds {
     if (self = [super initSkimNoteWithBounds:bounds]) {
+        if (SKPDFAnnotationLeaksBorder)
+            [[self border] release];
         NSColor *color = [[NSUserDefaults standardUserDefaults] 
colorForKey:SKCircleNoteInteriorColorKey];
         if ([color alphaComponent] > 0.0)
             [self setInteriorColor:color];

Modified: trunk/PDFAnnotationInk_SKExtensions.m
===================================================================
--- trunk/PDFAnnotationInk_SKExtensions.m       2010-08-19 17:09:41 UTC (rev 
6717)
+++ trunk/PDFAnnotationInk_SKExtensions.m       2010-08-19 17:51:02 UTC (rev 
6718)
@@ -52,6 +52,8 @@
 
 - (id)initSkimNoteWithBounds:(NSRect)bounds {   
     if (self = [super initSkimNoteWithBounds:bounds]) {         
+        if (SKPDFAnnotationLeaksBorder)
+            [[self border] release];
         [self setColor:[[NSUserDefaults standardUserDefaults] 
colorForKey:SKInkNoteColorKey]];          
         PDFBorder *border = [[PDFBorder allocWithZone:[self zone]] init];      
 
         [border setLineWidth:[[NSUserDefaults standardUserDefaults] 
floatForKey:SKInkNoteLineWidthKey]];        

Modified: trunk/PDFAnnotationSquare_SKExtensions.m
===================================================================
--- trunk/PDFAnnotationSquare_SKExtensions.m    2010-08-19 17:09:41 UTC (rev 
6717)
+++ trunk/PDFAnnotationSquare_SKExtensions.m    2010-08-19 17:51:02 UTC (rev 
6718)
@@ -50,6 +50,8 @@
 
 - (id)initSkimNoteWithBounds:(NSRect)bounds {
     if (self = [super initSkimNoteWithBounds:bounds]) {
+        if (SKPDFAnnotationLeaksBorder)
+            [[self border] release];
         NSColor *color = [[NSUserDefaults standardUserDefaults] 
colorForKey:SKSquareNoteInteriorColorKey];
         if ([color alphaComponent] > 0.0)
             [self setInteriorColor:color];

Modified: trunk/PDFAnnotation_SKExtensions.h
===================================================================
--- trunk/PDFAnnotation_SKExtensions.h  2010-08-19 17:09:41 UTC (rev 6717)
+++ trunk/PDFAnnotation_SKExtensions.h  2010-08-19 17:51:02 UTC (rev 6718)
@@ -70,9 +70,13 @@
 extern NSString *SKPDFAnnotationScriptingModificationDateKey;
 extern NSString *SKPDFAnnotationScriptingUserNameKey;
 
+extern BOOL SKPDFAnnotationLeaksBorder;
 
+
 @interface PDFAnnotation (SKExtensions)
 
++ (void)checkPDFKit;
+
 - (NSString *)fdfString;
 
 - (PDFDestination *)destination;

Modified: trunk/PDFAnnotation_SKExtensions.m
===================================================================
--- trunk/PDFAnnotation_SKExtensions.m  2010-08-19 17:09:41 UTC (rev 6717)
+++ trunk/PDFAnnotation_SKExtensions.m  2010-08-19 17:51:02 UTC (rev 6718)
@@ -56,6 +56,7 @@
 #import "NSData_SKExtensions.h"
 #import "NSString_SKExtensions.h"
 #import "NSBezierPath_SKExtensions.h"
+#import "SKVersionNumber.h"
 
 #define SKUseUserNameKey @"SKUseUserName"
 #define SKUserNameKey @"SKUserName"
@@ -90,12 +91,23 @@
 NSString *SKPDFAnnotationScriptingModificationDateKey = 
@"scriptingModificationDate";
 NSString *SKPDFAnnotationScriptingUserNameKey = @"scriptingUserName";
 
+BOOL SKPDFAnnotationLeaksBorder = NO;
+
 enum {
     SKPDFAnnotationScriptingNoteClassCode = 'Note'
 };
 
 @implementation PDFAnnotation (SKExtensions)
 
++ (void)checkPDFKit {
+    // Some PDFAnnotation subclasses over-retain the initial PDFBorder ivar, 
at least on PDFKit version 2.5 (MacOSX 10.6.0-2) and 2.5.1 (MacOSX 10.6.3-4)
+    SKVersionNumber *PDFKitVersion = [[SKVersionNumber alloc] 
initWithVersionString:[[NSBundle bundleForClass:self] 
objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey]];
+    SKVersionNumber *minVersion = [[SKVersionNumber alloc] 
initWithVersionString:@"2.5"];
+    SKVersionNumber *maxVersion = [[SKVersionNumber alloc] 
initWithVersionString:@"2.5.1"];
+    if ([PDFKitVersion compareToVersionNumber:minVersion] != 
NSOrderedAscending && [PDFKitVersion compareToVersionNumber:maxVersion] != 
NSOrderedDescending)
+        SKPDFAnnotationLeaksBorder = YES;
+}
+
 - (NSString *)fdfString {
     NSMutableString *fdfString = [NSMutableString string];
     NSRect bounds = [self bounds];

Modified: trunk/SKApplicationController.m
===================================================================
--- trunk/SKApplicationController.m     2010-08-19 17:09:41 UTC (rev 6717)
+++ trunk/SKApplicationController.m     2010-08-19 17:51:02 UTC (rev 6718)
@@ -77,6 +77,7 @@
 #import "SKLocalization.h"
 #import "SKScriptMenu.h"
 #import "NSScreen_SKExtensions.h"
+#import "PDFAnnotation_SKExtensions.h"
 
 #define WEBSITE_URL @"http://skim-app.sourceforge.net/";
 #define WIKI_URL    @"http://sourceforge.net/apps/mediawiki/skim-app/";
@@ -181,6 +182,7 @@
 
 - (void)applicationWillFinishLaunching:(NSNotification *)aNotification {
     [NSImage makeImages];
+    [PDFAnnotation checkPDFKit];
 }
 
 - (void)applicationDidFinishLaunching:(NSNotification *)aNotification{


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 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to