Esempio n. 1
0
 private static void DisplayErrorMessage(QProcess proc)
 {
     if (proc.ExitCode != 0)
     {
         if (proc.solutionString(proc.ExitCode) != null)
             Messages.DisplayErrorMessage(SR.GetString("Helpers_ExitError", proc.ExitCode.ToString())
                 + "\r\n" + proc.errorString(proc.ExitCode),
                 proc.solutionString(proc.ExitCode));
         else
             Messages.DisplayErrorMessage(SR.GetString("Helpers_ExitError", proc.ExitCode.ToString())
                 + "\r\n" + proc.errorString(proc.ExitCode));
     }
 }
Esempio n. 2
0
        public static void StartExternalQtApplication(string application, string arguments, string workingDir,
            EnvDTE.Project project, bool checkExitCode, Hashtable errorCodes)
        {
            proc = new QProcess();
            proc.ErrorCodes = errorCodes;
            proc.StartInfo.CreateNoWindow = true;
            proc.StartInfo.UseShellExecute = false;
            proc.EnableRaisingEvents = true;
            proc.StartInfo.WorkingDirectory = workingDir;
            proc.StartInfo.RedirectStandardError = true;
            proc.StartInfo.RedirectStandardOutput = true;

            EnvDTE.DTE dte = project.DTE;
            Messages.ActivateMessagePane();
            string qtDir = HelperFunctions.FindQtDirWithTools(project);

            proc.StartInfo.FileName = qtDir + application;
            proc.StartInfo.Arguments = arguments;
            if (checkExitCode && application.ToLower().IndexOf("uic.exe") > -1)
                proc.Exited += new EventHandler(QtApplicationExited);

            try
            {
                proc.Start();
                if (checkExitCode && application.ToLower().IndexOf("lupdate.exe") > -1 ||
                    checkExitCode && application.ToLower().IndexOf("lrelease.exe") > -1)
                {
                    System.Threading.Thread errorThread
                        = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(ReadQtStandardError));

                    errorThread.Start(dte);
                    proc.WaitForExit();
                    errorThread.Join();

                    int exitCode = proc.ExitCode;
                    if (exitCode == 0)
                    {
                        string arg = arguments;
                        int index = arg.IndexOf("-ts");
                        string file = "file: " + arg + " ";
                        if (index > 0)
                            file = "file: " + arg.Substring(index + 3) + " ";

                        FileInfo info = new FileInfo(application);
                        Messages.PaneMessage(project.DTE, "--- (" +
                            HelperFunctions.RemoveFileNameExtension(info) + ") " +
                            file + ": Exit Code: " + exitCode);
                    }
                    else
                    {
                        DisplayErrorMessage(proc);
                    }

                    proc.Close();
                }
            }
            catch
            {
                throw new Qt5VSException(SR.GetString("Helpers_CannotStart", proc.StartInfo.FileName));
            }
        }