discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Another NSApplication.m Patch


From: David Relson
Subject: Another NSApplication.m Patch
Date: Thu, 25 Jul 2002 11:44:49 -0400

Greetings,

While reading -[NSApplication terminate:], I noticed the "Enclose ... autorelease" comment and following block of code. Since the purpose of the block is to delete the global instance of NSApplication, I thought it might be better to define a class method that would complement +[NSApplication sharedApplication]. Below is a patch to create +[NSApplication sharedApplication].

David

--- NSApplication.m.cvs Thu Jul 25 11:33:33 2002
+++ NSApplication.m     Thu Jul 25 11:34:46 2002
@@ -527,6 +527,17 @@
   return NSApp;
 }

++ (void) deleteApplication
+{
+  NSAutoreleasePool *pool = nil;
+
+  IF_NO_GC(pool = [arpClass new]);
+
+  DESTROY(NSApp);
+
+  DESTROY(pool);
+}
+
 /*
  * Instance methods
  */
@@ -2368,18 +2379,8 @@
         pools which might have been created inside this one).  */
       DESTROY (_runLoopPool);

-      /* Now free the NSApplication object.  Enclose the operation
-        into an autorelease pool, in case some -dealloc method needs
-        to use any temporary object.  */
-      {
-       NSAutoreleasePool *pool;
-       
-       IF_NO_GC(pool = [arpClass new]);
-
-       DESTROY(NSApp);
-
-       DESTROY(pool);
-      }
+      /* Now free the NSApplication object.  */
+      [ NSApplication deleteApplication ];

       /* And finally, stop the program.  */
       exit(0);
--------------------------------------------------------
David Relson                   Osage Software Systems, Inc.
relson@osagesoftware.com       Ann Arbor, MI 48103
www.osagesoftware.com          tel:  734.821.8800




reply via email to

[Prev in Thread] Current Thread [Next in Thread]