Przeglądaj źródła

Merge pull request #1120 from AtomicGameEngine/JME-ATOMIC-1119

Fix for space in argument, when argument is already quoted
JoshEngebretson 9 lat temu
rodzic
commit
081fb6e67b

+ 15 - 0
Source/Atomic/Core/ProcessUtils.cpp

@@ -489,4 +489,19 @@ String GetMiniDumpDir()
     return miniDumpDir;
 }
 
+// ATOMIC BEGIN
+
+void QuoteArguments(Vector<String>& args)
+{
+    for (unsigned i = 0; i < args.Size(); i++)
+    {
+        if (args[i].Contains(' ') && !args[i].Contains('"'))
+        {
+            args[i] = "\"" + args[i] + "\"";
+        }
+    }
+}
+
+// ATOMIC END
+
 }

+ 7 - 0
Source/Atomic/Core/ProcessUtils.h

@@ -70,4 +70,11 @@ ATOMIC_API void SetMiniDumpDir(const String& pathName);
 /// Return minidump write location.
 ATOMIC_API String GetMiniDumpDir();
 
+// ATOMIC BEGIN
+
+/// Encloses arguments that contain space in quotes
+ATOMIC_API void QuoteArguments(Vector<String>& args);
+
+// ATOMIC END
+
 }

+ 2 - 6
Source/AtomicApp/AppBase.cpp

@@ -51,13 +51,9 @@ namespace Atomic
         else
         {
             // Add quotes to any arguments that need them, and construct command line
-
             Vector<String> args = arguments_;
-            for (unsigned i = 0; i < args.Size(); i++)
-            {
-                if (arguments_[i].Contains(" "))
-                    args[i] = ToString("\"%s\"", arguments_[i].CString());
-            }
+
+            QuoteArguments(args);
 
             String commandline = String::Joined(args, " ");
 

+ 27 - 13
Source/ToolCore/NETTools/NETProjectSystem.cpp

@@ -23,6 +23,7 @@
 #include <Poco/Environment.h>
 
 #include <Atomic/Core/CoreEvents.h>
+#include <Atomic/Core/ProcessUtils.h>
 
 #include <Atomic/IO/Log.h>
 #include <Atomic/IO/FileSystem.h>
@@ -107,7 +108,11 @@ namespace ToolCore
             args.Push(solutionPath_);
 
             if (sourceFilePath.Length())
-                args.Push(sourceFilePath);                       
+                args.Push(sourceFilePath);
+
+#ifndef ATOMIC_PLATFORM_OSX
+            QuoteArguments(args);
+#endif
 
             try
             {
@@ -125,7 +130,7 @@ namespace ToolCore
                 return;
 
             try
-            {                
+            {
                 std::vector<std::string> args;
 
 #ifdef ATOMIC_PLATFORM_WINDOWS
@@ -143,7 +148,16 @@ namespace ToolCore
                 args.push_back(idePath_.CString());
 
 #endif
+
+#ifdef ATOMIC_PLATFORM_OSX
                 args.push_back(sourceFilePath.CString());
+#else
+                if (sourceFilePath.Contains(" ") && !sourceFilePath.Contains("\""))
+                    args.push_back(("\"" + sourceFilePath + "\"").CString());
+                else
+                    args.push_back(sourceFilePath.CString());
+#endif
+
                 Poco::Process::launch(command.CString(), args);
 
             }
@@ -289,14 +303,14 @@ namespace ToolCore
 
         if (solutionDirty_)
         {
-            // set to false in case of error, we don't want to keep trying to 
+            // set to false in case of error, we don't want to keep trying to
             // rebuild, TODO: better error handling
             solutionDirty_ = false;
             GenerateSolution();
         }
 
         if (projectAssemblyDirty_)
-        {        
+        {
             BuildAtomicProject();
             projectAssemblyDirty_ = false;
         }
@@ -308,8 +322,8 @@ namespace ToolCore
         using namespace ProjectLoaded;
 
         String projectPath = eventData[P_PROJECTPATH].GetString();
-        Project* project = static_cast<Project*>(eventData[P_PROJECT].GetPtr());        
-        
+        Project* project = static_cast<Project*>(eventData[P_PROJECT].GetPtr());
+
         if (GetExtension(projectPath) == ".atomic")
             projectPath = GetParentPath(projectPath);
 
@@ -329,10 +343,10 @@ namespace ToolCore
             if (!results.Size())
             {
                 solutionPath_.Clear();
-                return;                
+                return;
             }
-                
-        }            
+
+        }
 
         // if the solution or project assemblies don't exist mark as dirty
 
@@ -353,13 +367,13 @@ namespace ToolCore
     {
         if (solutionDirty_)
         {
-            // set to false in case of error, we don't want to keep trying to 
+            // set to false in case of error, we don't want to keep trying to
             // rebuild, TODO: better error handling
             solutionDirty_ = false;
             GenerateSolution();
         }
     }
-    
+
     void NETProjectSystem::HandleProjectUnloaded(StringHash eventType, VariantMap& eventData)
     {
         Clear();
@@ -384,7 +398,7 @@ namespace ToolCore
 
     void NETProjectSystem::HandleResourceAdded(StringHash eventType, VariantMap& eventData)
     {
-        
+
     }
 
     void NETProjectSystem::HandleResourceRemoved(StringHash eventType, VariantMap& eventData)
@@ -402,7 +416,7 @@ namespace ToolCore
 
     }
 
-    void NETProjectSystem::Initialize()    
+    void NETProjectSystem::Initialize()
     {
         Clear();
 

+ 2 - 2
Source/ToolCore/NETTools/NETProjectSystem.h

@@ -57,11 +57,11 @@ namespace ToolCore
 
         const String& GetSolutionPath() const { return solutionPath_; }
 
-        void BuildAtomicProject();        
+        void BuildAtomicProject();
 
         /// Open the solution, if opening a source file, better to call OpenSourceFile as will launch VS instance with source file loaded
         /// otherwise, no guarantee where source file will load when multiple VS instances running
-        void OpenSolution();       
+        void OpenSolution();
 
         void OpenSourceFile(const String& sourceFilePath);