[niftyplugins] r81 committed - Fix for Issue 46: Crash of Visual Studio if perforce directory not in ...

0 views
Skip to first unread message

codesite...@google.com

unread,
Oct 29, 2009, 2:26:31 AM10/29/09
to niftyplug...@googlegroups.com
Revision: 81
Author: jim.tilander
Date: Wed Oct 28 23:25:57 2009
Log: Fix for Issue 46: Crash of Visual Studio if perforce directory not in
PATH environment variable


http://code.google.com/p/niftyplugins/issues/detail?id=46


http://code.google.com/p/niftyplugins/source/detail?r=81

Modified:
/trunk/NiftyPerforce/P4Operations.cs

=======================================
--- /trunk/NiftyPerforce/P4Operations.cs Mon Jul 6 22:34:10 2009
+++ /trunk/NiftyPerforce/P4Operations.cs Wed Oct 28 23:25:57 2009
@@ -188,47 +188,55 @@

public static bool RunCommand(OutputWindowPane output, string
executableName, string command, string workingDirectory, int sequence)
{
- System.Diagnostics.Process process = new System.Diagnostics.Process();
- process.StartInfo.UseShellExecute = false;
- process.StartInfo.FileName = executableName;
- process.StartInfo.RedirectStandardOutput = true;
- process.StartInfo.RedirectStandardError = true;
- process.StartInfo.CreateNoWindow = true;
- process.StartInfo.WorkingDirectory = workingDirectory;
- process.StartInfo.Arguments = command;
- if (!process.Start())
- {
- if (null != output)
- {
- output.OutputString(string.Format( "{0}: Failed to start {1}. Is
Perforce installed and in the path?\n", sequence, executableName ));
- }
- return false;
- }
- process.WaitForExit();
-
- string stdOut = process.StandardOutput.ReadToEnd();
- string stdErr = process.StandardError.ReadToEnd();
-
- if (null != output)
- {
- output.OutputString(sequence.ToString() + ": " + executableName + " "
+ command + "\n");
- output.OutputString(stdOut);
- output.OutputString(stdErr);
- }
-
- System.Diagnostics.Debug.WriteLine(command + "\n");
- System.Diagnostics.Debug.WriteLine(stdOut);
- System.Diagnostics.Debug.WriteLine(stdErr);
-
- if (0 != process.ExitCode)
- {
- if (null != output)
- {
- output.OutputString(sequence.ToString() + ":
Process exit code was " + process.ExitCode + ".\n");
- }
+ try
+ {
+ System.Diagnostics.Process process = new System.Diagnostics.Process();
+ process.StartInfo.UseShellExecute = false;
+ process.StartInfo.FileName = executableName;
+ process.StartInfo.RedirectStandardOutput = true;
+ process.StartInfo.RedirectStandardError = true;
+ process.StartInfo.CreateNoWindow = true;
+ process.StartInfo.WorkingDirectory = workingDirectory;
+ process.StartInfo.Arguments = command;
+ if(!process.Start())
+ {
+ if(null != output)
+ {
+ output.OutputString(string.Format("{0}: Failed to start {1}. Is
Perforce installed and in the path?\n", sequence, executableName));
+ }
+ return false;
+ }
+ process.WaitForExit();
+
+ string stdOut = process.StandardOutput.ReadToEnd();
+ string stdErr = process.StandardError.ReadToEnd();
+
+ if(null != output)
+ {
+ output.OutputString(sequence.ToString() + ": " + executableName
+ " " + command + "\n");
+ output.OutputString(stdOut);
+ output.OutputString(stdErr);
+ }
+
+ System.Diagnostics.Debug.WriteLine(command + "\n");
+ System.Diagnostics.Debug.WriteLine(stdOut);
+ System.Diagnostics.Debug.WriteLine(stdErr);
+
+ if(0 != process.ExitCode)
+ {
+ if(null != output)
+ {
+ output.OutputString(sequence.ToString() + ": Process exit code
was " + process.ExitCode + ".\n");
+ }
+ return false;
+ }
+ return true;
+ }
+ catch(System.ComponentModel.Win32Exception e)
+ {
+ output.OutputString("Failed to spawn process: " + e.ToString());
return false;
}
- return true;
}

private class Command

Reply all
Reply to author
Forward
0 new messages