Revision: 4171
          http://skim-app.svn.sourceforge.net/skim-app/?rev=4171&view=rev
Author:   hofman
Date:     2008-07-09 17:55:10 -0700 (Wed, 09 Jul 2008)

Log Message:
-----------
Make skimnotes tool GC safe and support GC with the appropriate build config.

Modified Paths:
--------------
    trunk/SkimNotes/SKNAgentListener.m
    trunk/SkimNotes/SkimNotes.rtf
    trunk/SkimNotes/skimnotes.m

Modified: trunk/SkimNotes/SKNAgentListener.m
===================================================================
--- trunk/SkimNotes/SKNAgentListener.m  2008-07-10 00:10:25 UTC (rev 4170)
+++ trunk/SkimNotes/SKNAgentListener.m  2008-07-10 00:55:10 UTC (rev 4171)
@@ -79,6 +79,15 @@
     [super dealloc];
 }
 
+#if defined(MAC_OS_X_VERSION_10_5) && MAC_OS_X_VERSION_MAX_ALLOWED >= 
MAC_OS_X_VERSION_10_5
+- (void)finalize
+{
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
+    [self destroyConnection];
+    [super finalize];
+}
+#endif
+
 - (NSString *)notesFileWithExtension:(NSString *)extension atPath:(NSString 
*)path error:(NSError **)error {
     NSString *filePath = nil;
     

Modified: trunk/SkimNotes/SkimNotes.rtf
===================================================================
--- trunk/SkimNotes/SkimNotes.rtf       2008-07-10 00:10:25 UTC (rev 4170)
+++ trunk/SkimNotes/SkimNotes.rtf       2008-07-10 00:55:10 UTC (rev 4171)
@@ -100,7 +100,7 @@
 Garbage Collection and 64-Bits
 \b0 \
 \
-The built versions of the SkimNotes framework and skimnotes tool included in 
the release are built using the Release configuration.  This means that Garbage 
Collection (GC) and 64-bits are not supported.  The Xcode project has a build 
configuration called "Release (GC dual-mode)" that builds the framework with GC 
supported (not required) and includes a 64-bit binary for Intel.  The framework 
should be safe for GC and 64-bits when build with this configuration, but you 
should be aware that it has not been tested in these environment.  The 
framework built with this configuration requires Mac OSX 10.5.  For the 
skimnotes tool the "Release (GC dual-mode)" configuration is the same as for 
the Release configuration, as the code has not been fully checked for 
compatibility with GC and 64-bits.  It should also not be relevant for the 
tool.\
+The built versions of the SkimNotes framework and skimnotes tool included in 
the release are built using the Release configuration.  This means that Garbage 
Collection (GC) and 64-bits are not supported.  The Xcode project has a build 
configuration called "Release (GC dual-mode)" that builds the framework with GC 
supported (not required) and includes a 64-bit binary for Intel.  The framework 
should be safe for GC and 64-bits when build with this configuration, but you 
should be aware that it has not been tested in these environment.  The 
framework built with this configuration requires Mac OSX 10.5.\
 
 \b \
 Smaller SkimNotes Framework

Modified: trunk/SkimNotes/skimnotes.m
===================================================================
--- trunk/SkimNotes/skimnotes.m 2008-07-10 00:10:25 UTC (rev 4170)
+++ trunk/SkimNotes/skimnotes.m 2008-07-10 00:55:10 UTC (rev 4171)
@@ -68,14 +68,22 @@
     return path;
 }
 
+#if !defined(MAC_OS_X_VERSION_10_5) || MAC_OS_X_VERSION_MAX_ALLOWED < 
MAC_OS_X_VERSION_10_5
+#define DRAIN(pool) [pool release]
+#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
+#define DRAIN(pool) ([pool respondsToSelector:@selector(drain)] ? [pool drain] 
: [pool release])
+#else
+#define DRAIN(pool) [pool drain]
+#endif
+
 int main (int argc, const char * argv[]) {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    NSAutoreleasePool *pool = [NSAutoreleasePool new];
  
     NSArray *args = [[NSProcessInfo processInfo] arguments];
     
     if (argc < 2) {
         fprintf (stderr, "%s\n%s\n", usageStr, versionStr);
-        [pool release];
+        DRAIN(pool);
         exit (1);
     }
     
@@ -87,18 +95,23 @@
         
         NSString *serverName = [args count] > 2 ? [args lastObject] : nil;
         SKNAgentListener *listener = [[SKNAgentListener alloc] 
initWithServerName:serverName];
-
+        
         NSRunLoop *rl = [NSRunLoop currentRunLoop];
         BOOL didRun;
-        NSDate *distantFuture = [NSDate distantFuture];
+        NSDate *distantFuture = (id)CFRetain([NSDate distantFuture]);
         
+        [(id)CFRetain(listener) release];
+        
+        DRAIN(pool);
         do {
-            [pool release];
             pool = [NSAutoreleasePool new];
             didRun = [rl runMode:NSDefaultRunLoopMode 
beforeDate:distantFuture];
+            DRAIN(pool);
         } while (listener && didRun);
+        pool = [NSAutoreleasePool new];
         
-        [listener release];
+        CFRelease(listener);
+        CFRelease(distantFuture);
         
         success = YES;
         
@@ -146,7 +159,7 @@
         
         if (argc < 3) {
             fprintf (stderr, "%s\n%s\n", usageStr, versionStr);
-            [pool release];
+            DRAIN(pool);
             exit (1);
         }
         
@@ -157,7 +170,7 @@
         if ([[args objectAtIndex:2] isEqualToString:@"-format"]) {
             if (argc < 5) {
                 fprintf (stderr, "%s\n%s\n", usageStr, versionStr);
-                [pool release];
+                DRAIN(pool);
                 exit (1);
             }
             offset = 4;
@@ -260,7 +273,7 @@
         
     }
     
-    [pool release];
+    DRAIN(pool);
     
     return success ? 0 : 1;
 }


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

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to