[Lldb-commits] [lldb] r112558 - /lldb/trunk/source/Host/macosx/Host.mm

Jim Ingham jingham at apple.com
Mon Aug 30 16:48:26 PDT 2010


Author: jingham
Date: Mon Aug 30 18:48:25 2010
New Revision: 112558

URL: http://llvm.org/viewvc/llvm-project?rev=112558&view=rev
Log:
Add LLDB_EXTERNAL_EDITOR

Modified:
    lldb/trunk/source/Host/macosx/Host.mm

Modified: lldb/trunk/source/Host/macosx/Host.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=112558&r1=112557&r2=112558&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/Host.mm (original)
+++ lldb/trunk/source/Host/macosx/Host.mm Mon Aug 30 18:48:25 2010
@@ -829,15 +829,47 @@
     file_and_line_desc.descKey = keyAEPosition;
     
     LSApplicationParameters app_params;
+    static FSRef app_to_use;
+    static std::string app_name;
     bzero (&app_params, sizeof (app_params));
     app_params.flags = kLSLaunchDefaults | 
                        kLSLaunchDontAddToRecents | 
                        kLSLaunchDontSwitch;
+                       
+    char *external_editor = ::getenv ("LLDB_EXTERNAL_EDITOR");
+    
+    if (external_editor != NULL)
+    {
+        bool calculate_fsref = true;
+        if (app_name.empty() || strcmp (app_name.c_str(), external_editor) != 0)
+        {
+            calculate_fsref = true;
+        }
+        else
+            calculate_fsref = false;
+            
+        if (calculate_fsref)
+        {
+            CFCString editor_name (external_editor, kCFStringEncodingUTF8);
+            error = ::LSFindApplicationForInfo(kLSUnknownCreator, NULL, editor_name.get(), &app_to_use, NULL);
+            
+            // If we found the app, then store away the name so we don't have to re-look it up.
+            if (error == noErr)
+                app_name.assign (external_editor);
+            else
+                return false;
+                
+        }
+        
+        app_params.application = &app_to_use;
+    }
+
+
 
     ProcessSerialNumber psn;
     CFCReleaser<CFArrayRef> file_array(CFArrayCreate (NULL, (const void **) file_URL.ptr_address(false), 1, NULL));
     error = ::LSOpenURLsWithRole (file_array.get(), 
-                                  kLSRolesViewer, 
+                                  kLSRolesAll, 
                                   &file_and_line_desc, 
                                   &app_params, 
                                   &psn, 





More information about the lldb-commits mailing list