bug-gnustep
[Top][All Lists]
Advanced

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

Re: NSWorkspace -fullPathForApplication: broken [patch]


From: Jeff Teunissen
Subject: Re: NSWorkspace -fullPathForApplication: broken [patch]
Date: Sun, 16 Jun 2002 14:05:05 -0400

Jeff Teunissen wrote:

> Attached is a patch which fixes -fullPathForApplication: so that it is
> able to find applications both with and without the extension. As an
> additional benefit, it is now also able to find apps with a .debug or a
> .profile extension (and be able to contact them), just like OPENSTEP
> does.
> 
> With this patch applied, gopen is able to work in both of the above
> cases.

Okay, so I lied. It segfaulted when you actually gave an extension, as
should have been obvious.

Ignore the last one, this one is correct.

-- 
| Jeff Teunissen  -=-  Pres., Dusk To Dawn Computing  -=-  deek @ d2dc.net
| GPG: 1024D/9840105A   7102 808A 7733 C2F3 097B  161B 9222 DAB8 9840 105A
| Core developer, The QuakeForge Project        http://www.quakeforge.net/
| Specializing in Debian GNU/Linux              http://www.d2dc.net/~deek/
Index: gui/Source/NSWorkspace.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/gui/Source/NSWorkspace.m,v
retrieving revision 1.49
diff -u -r1.49 NSWorkspace.m
--- gui/Source/NSWorkspace.m    28 Mar 2002 13:23:38 -0000      1.49
+++ gui/Source/NSWorkspace.m    16 Jun 2002 18:02:59 -0000
@@ -501,16 +501,33 @@
 - (NSString*) fullPathForApplication: (NSString*)appName
 {
   NSString      *last = [appName lastPathComponent];
+  NSString     *path = nil;
 
-  if ([appName isEqual: last])
+  if (appName != nil && [appName isEqual: last])
     {
       NSString  *ext = [appName pathExtension];
 
-      if (ext == nil)
-        {
-          appName = [appName stringByAppendingPathExtension: @"app"];
-        }
-      return [applications objectForKey: appName];
+      if ([ext isEqual: @""])
+       {
+         path = [appName stringByAppendingPathExtension: @"app"];
+         path = [applications objectForKey: path];
+
+         if (path == nil)
+           {
+             path = [appName stringByAppendingPathExtension: @"debug"];
+             path = [applications objectForKey: path];
+           }
+         if (path == nil)
+           {
+             path = [appName stringByAppendingPathExtension: @"profile"];
+             path = [applications objectForKey: path];
+           }
+       }
+      else
+       {
+         path = [applications objectForKey: appName];
+       }
+      return path;
     }
   return nil;
 }
@@ -1091,30 +1108,26 @@
 {
   NSString     *path;
 
-  if (appName == nil)
+  /*
+   * Testing for nil doesn't catch empty strings
+   */
+  if (appName == nil || [appName isEqual: @""])
     {
       return nil;
     }
-  path = appName;
-  appName = [path lastPathComponent];
-  if ([appName isEqual: path])
-    {
-      path = [self fullPathForApplication: appName];
-      appName = [[path lastPathComponent] stringByDeletingPathExtension];
-    }
-  else if ([appName pathExtension] == nil)
-    {
-      path = [path stringByAppendingPathExtension: @"app"];
-    }
-  else
-    {
-      appName = [[path lastPathComponent] stringByDeletingPathExtension];
-    }
+
+  path = [self fullPathForApplication: appName];
 
   if (path == nil)
     {
       return nil;
     }
+
+  /*
+   * We need to set appName to the real app name (e.g. Ink, not Ink.app), or
+   * connecting to an already-running app will not work.
+   */
+  appName = [[path lastPathComponent] stringByDeletingPathExtension];
 
   return [NSBundle bundleWithPath: path];
 }

reply via email to

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