forked from qt-creator/qt-creator
ConsoleProcess: undo pointless processError() => processMessage(bool error) change
This commit is contained in:
@@ -95,7 +95,7 @@ public:
|
||||
#endif
|
||||
|
||||
signals:
|
||||
void processMessage(const QString &message, bool isError);
|
||||
void processError(const QString &error);
|
||||
// These reflect the state of the actual client process
|
||||
void processStarted();
|
||||
void processStopped();
|
||||
|
||||
@@ -83,13 +83,13 @@ bool ConsoleProcess::start(const QString &program, const QString &args)
|
||||
pcmd = program;
|
||||
} else {
|
||||
if (perr != QtcProcess::FoundMeta) {
|
||||
emit processMessage(tr("Quoting error in command."), true);
|
||||
emit processError(tr("Quoting error in command."));
|
||||
return false;
|
||||
}
|
||||
if (d->m_mode == Debug) {
|
||||
// FIXME: QTCREATORBUG-2809
|
||||
emit processMessage(tr("Debugging complex shell commands in a terminal"
|
||||
" is currently not supported."), true);
|
||||
emit processError(tr("Debugging complex shell commands in a terminal"
|
||||
" is currently not supported."));
|
||||
return false;
|
||||
}
|
||||
pcmd = QLatin1String("/bin/sh");
|
||||
@@ -100,15 +100,15 @@ bool ConsoleProcess::start(const QString &program, const QString &args)
|
||||
QStringList xtermArgs = QtcProcess::prepareArgs(terminalEmulator(d->m_settings), &qerr,
|
||||
&d->m_environment, &d->m_workingDir);
|
||||
if (qerr != QtcProcess::SplitOk) {
|
||||
emit processMessage(qerr == QtcProcess::BadQuoting
|
||||
? tr("Quoting error in terminal command.")
|
||||
: tr("Terminal command may not be a shell command."), true);
|
||||
emit processError(qerr == QtcProcess::BadQuoting
|
||||
? tr("Quoting error in terminal command.")
|
||||
: tr("Terminal command may not be a shell command."));
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString err = stubServerListen();
|
||||
if (!err.isEmpty()) {
|
||||
emit processMessage(msgCommChannelFailed(err), true);
|
||||
emit processError(msgCommChannelFailed(err));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ bool ConsoleProcess::start(const QString &program, const QString &args)
|
||||
d->m_tempFile = new QTemporaryFile();
|
||||
if (!d->m_tempFile->open()) {
|
||||
stubServerShutdown();
|
||||
emit processMessage(msgCannotCreateTempFile(d->m_tempFile->errorString()), true);
|
||||
emit processError(msgCannotCreateTempFile(d->m_tempFile->errorString()));
|
||||
delete d->m_tempFile;
|
||||
d->m_tempFile = 0;
|
||||
return false;
|
||||
@@ -129,7 +129,7 @@ bool ConsoleProcess::start(const QString &program, const QString &args)
|
||||
}
|
||||
if (d->m_tempFile->write(contents) != contents.size() || !d->m_tempFile->flush()) {
|
||||
stubServerShutdown();
|
||||
emit processMessage(msgCannotWriteTempFile(), true);
|
||||
emit processError(msgCannotWriteTempFile());
|
||||
delete d->m_tempFile;
|
||||
d->m_tempFile = 0;
|
||||
return false;
|
||||
@@ -153,7 +153,7 @@ bool ConsoleProcess::start(const QString &program, const QString &args)
|
||||
d->m_process.start(xterm, xtermArgs);
|
||||
if (!d->m_process.waitForStarted()) {
|
||||
stubServerShutdown();
|
||||
emit processMessage(tr("Cannot start the terminal emulator '%1'.").arg(xterm), true);
|
||||
emit processError(tr("Cannot start the terminal emulator '%1'.").arg(xterm));
|
||||
delete d->m_tempFile;
|
||||
d->m_tempFile = 0;
|
||||
return false;
|
||||
@@ -234,9 +234,9 @@ void ConsoleProcess::readStubOutput()
|
||||
QByteArray out = d->m_stubSocket->readLine();
|
||||
out.chop(1); // \n
|
||||
if (out.startsWith("err:chdir ")) {
|
||||
emit processMessage(msgCannotChangeToWorkDir(workingDirectory(), errorMsg(out.mid(10).toInt())), true);
|
||||
emit processError(msgCannotChangeToWorkDir(workingDirectory(), errorMsg(out.mid(10).toInt())));
|
||||
} else if (out.startsWith("err:exec ")) {
|
||||
emit processMessage(msgCannotExecute(d->m_executable, errorMsg(out.mid(9).toInt())), true);
|
||||
emit processError(msgCannotExecute(d->m_executable, errorMsg(out.mid(9).toInt())));
|
||||
} else if (out.startsWith("pid ")) {
|
||||
// Will not need it any more
|
||||
delete d->m_tempFile;
|
||||
@@ -255,7 +255,7 @@ void ConsoleProcess::readStubOutput()
|
||||
d->m_appPid = 0;
|
||||
emit processStopped();
|
||||
} else {
|
||||
emit processMessage(msgUnexpectedOutput(out), true);
|
||||
emit processError(msgUnexpectedOutput(out));
|
||||
d->m_process.terminate();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ bool ConsoleProcess::start(const QString &program, const QString &args)
|
||||
|
||||
const QString err = stubServerListen();
|
||||
if (!err.isEmpty()) {
|
||||
emit processMessage(msgCommChannelFailed(err), true);
|
||||
emit processError(msgCommChannelFailed(err));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ bool ConsoleProcess::start(const QString &program, const QString &args)
|
||||
d->m_tempFile = new QTemporaryFile();
|
||||
if (!d->m_tempFile->open()) {
|
||||
stubServerShutdown();
|
||||
emit processMessage(msgCannotCreateTempFile(d->m_tempFile->errorString()), true);
|
||||
emit processError(msgCannotCreateTempFile(d->m_tempFile->errorString()));
|
||||
delete d->m_tempFile;
|
||||
d->m_tempFile = 0;
|
||||
return false;
|
||||
@@ -106,7 +106,7 @@ bool ConsoleProcess::start(const QString &program, const QString &args)
|
||||
out.flush();
|
||||
if (out.status() != QTextStream::Ok) {
|
||||
stubServerShutdown();
|
||||
emit processMessage(msgCannotWriteTempFile(), true);
|
||||
emit processError(msgCannotWriteTempFile());
|
||||
delete d->m_tempFile;
|
||||
d->m_tempFile = 0;
|
||||
return false;
|
||||
@@ -147,7 +147,7 @@ bool ConsoleProcess::start(const QString &program, const QString &args)
|
||||
delete d->m_tempFile;
|
||||
d->m_tempFile = 0;
|
||||
stubServerShutdown();
|
||||
emit processMessage(tr("The process '%1' could not be started: %2").arg(cmdLine, winErrorMessage(GetLastError())), true);
|
||||
emit processError(tr("The process '%1' could not be started: %2").arg(cmdLine, winErrorMessage(GetLastError())));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -204,9 +204,9 @@ void ConsoleProcess::readStubOutput()
|
||||
QByteArray out = d->m_stubSocket->readLine();
|
||||
out.chop(2); // \r\n
|
||||
if (out.startsWith("err:chdir ")) {
|
||||
emit processMessage(msgCannotChangeToWorkDir(workingDirectory(), winErrorMessage(out.mid(10).toInt())), true);
|
||||
emit processError(msgCannotChangeToWorkDir(workingDirectory(), winErrorMessage(out.mid(10).toInt())));
|
||||
} else if (out.startsWith("err:exec ")) {
|
||||
emit processMessage(msgCannotExecute(d->m_executable, winErrorMessage(out.mid(9).toInt())), true);
|
||||
emit processError(msgCannotExecute(d->m_executable, winErrorMessage(out.mid(9).toInt())));
|
||||
} else if (out.startsWith("thread ")) { // Windows only
|
||||
d->m_appMainThreadId = out.mid(7).toLongLong();
|
||||
} else if (out.startsWith("pid ")) {
|
||||
@@ -219,8 +219,8 @@ void ConsoleProcess::readStubOutput()
|
||||
SYNCHRONIZE | PROCESS_QUERY_INFORMATION | PROCESS_TERMINATE,
|
||||
FALSE, d->m_appPid);
|
||||
if (d->m_hInferior == NULL) {
|
||||
emit processMessage(tr("Cannot obtain a handle to the inferior: %1")
|
||||
.arg(winErrorMessage(GetLastError())), true);
|
||||
emit processError(tr("Cannot obtain a handle to the inferior: %1")
|
||||
.arg(winErrorMessage(GetLastError())));
|
||||
// Uhm, and now what?
|
||||
continue;
|
||||
}
|
||||
@@ -228,7 +228,7 @@ void ConsoleProcess::readStubOutput()
|
||||
connect(d->inferiorFinishedNotifier, SIGNAL(activated(HANDLE)), SLOT(inferiorExited()));
|
||||
emit processStarted();
|
||||
} else {
|
||||
emit processMessage(msgUnexpectedOutput(out), true);
|
||||
emit processError(msgUnexpectedOutput(out));
|
||||
TerminateProcess(d->m_pid->hProcess, (unsigned)-1);
|
||||
break;
|
||||
}
|
||||
@@ -249,8 +249,8 @@ void ConsoleProcess::inferiorExited()
|
||||
DWORD chldStatus;
|
||||
|
||||
if (!GetExitCodeProcess(d->m_hInferior, &chldStatus))
|
||||
emit processMessage(tr("Cannot obtain exit status from inferior: %1")
|
||||
.arg(winErrorMessage(GetLastError())), true);
|
||||
emit processError(tr("Cannot obtain exit status from inferior: %1")
|
||||
.arg(winErrorMessage(GetLastError())));
|
||||
cleanupInferior();
|
||||
d->m_appStatus = QProcess::NormalExit;
|
||||
d->m_appCode = chldStatus;
|
||||
|
||||
@@ -614,8 +614,8 @@ bool CdbEngine::startConsole(const DebuggerStartParameters &sp, QString *errorMe
|
||||
qDebug("startConsole %s", qPrintable(sp.executable));
|
||||
m_consoleStub.reset(new Utils::ConsoleProcess);
|
||||
m_consoleStub->setMode(Utils::ConsoleProcess::Suspend);
|
||||
connect(m_consoleStub.data(), SIGNAL(processMessage(QString, bool)),
|
||||
SLOT(consoleStubMessage(QString, bool)));
|
||||
connect(m_consoleStub.data(), SIGNAL(processError(QString)),
|
||||
SLOT(consoleStubError(QString)));
|
||||
connect(m_consoleStub.data(), SIGNAL(processStarted()),
|
||||
SLOT(consoleStubProcessStarted()));
|
||||
connect(m_consoleStub.data(), SIGNAL(wrapperStopped()),
|
||||
@@ -630,22 +630,18 @@ bool CdbEngine::startConsole(const DebuggerStartParameters &sp, QString *errorMe
|
||||
return true;
|
||||
}
|
||||
|
||||
void CdbEngine::consoleStubMessage(const QString &msg, bool isError)
|
||||
void CdbEngine::consoleStubError(const QString &msg)
|
||||
{
|
||||
if (debug)
|
||||
qDebug("consoleStubProcessMessage() in %s error=%d %s", stateName(state()), isError, qPrintable(msg));
|
||||
if (isError) {
|
||||
if (state() == EngineSetupRequested) {
|
||||
STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyEngineSetupFailed")
|
||||
notifyEngineSetupFailed();
|
||||
} else {
|
||||
STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyEngineIll")
|
||||
notifyEngineIll();
|
||||
}
|
||||
nonModalMessageBox(QMessageBox::Critical, tr("Debugger Error"), msg);
|
||||
qDebug("consoleStubProcessMessage() in %s %s", stateName(state()), qPrintable(msg));
|
||||
if (state() == EngineSetupRequested) {
|
||||
STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyEngineSetupFailed")
|
||||
notifyEngineSetupFailed();
|
||||
} else {
|
||||
showMessage(msg, AppOutput);
|
||||
STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyEngineIll")
|
||||
notifyEngineIll();
|
||||
}
|
||||
nonModalMessageBox(QMessageBox::Critical, tr("Debugger Error"), msg);
|
||||
}
|
||||
|
||||
void CdbEngine::consoleStubProcessStarted()
|
||||
|
||||
@@ -160,7 +160,7 @@ private slots:
|
||||
void postCommandSequence(unsigned mask);
|
||||
void operateByInstructionTriggered(bool);
|
||||
|
||||
void consoleStubMessage(const QString &, bool);
|
||||
void consoleStubError(const QString &);
|
||||
void consoleStubProcessStarted();
|
||||
void consoleStubExited();
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ TermGdbAdapter::TermGdbAdapter(GdbEngine *engine)
|
||||
m_stubProc.setSettings(Core::ICore::instance()->settings());
|
||||
#endif
|
||||
|
||||
connect(&m_stubProc, SIGNAL(processMessage(QString, bool)), SLOT(stubMessage(QString, bool)));
|
||||
connect(&m_stubProc, SIGNAL(processError(QString)), SLOT(stubError(QString)));
|
||||
connect(&m_stubProc, SIGNAL(processStarted()), SLOT(handleInferiorSetupOk()));
|
||||
connect(&m_stubProc, SIGNAL(wrapperStopped()), SLOT(stubExited()));
|
||||
}
|
||||
@@ -207,7 +207,7 @@ void TermGdbAdapter::interruptInferior()
|
||||
showMessage(_("CANNOT INTERRUPT %1").arg(attachedPID));
|
||||
}
|
||||
|
||||
void TermGdbAdapter::stubMessage(const QString &msg, bool)
|
||||
void TermGdbAdapter::stubError(const QString &msg)
|
||||
{
|
||||
showMessageBox(QMessageBox::Critical, tr("Debugger Error"), msg);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ private:
|
||||
|
||||
Q_SLOT void handleInferiorSetupOk();
|
||||
Q_SLOT void stubExited();
|
||||
Q_SLOT void stubMessage(const QString &msg, bool isError);
|
||||
Q_SLOT void stubError(const QString &msg);
|
||||
|
||||
Utils::ConsoleProcess m_stubProc;
|
||||
LocalGdbProcess m_gdbProc;
|
||||
|
||||
@@ -103,8 +103,8 @@ ApplicationLauncher::ApplicationLauncher(QObject *parent)
|
||||
#ifdef Q_OS_UNIX
|
||||
d->m_consoleProcess.setSettings(Core::ICore::instance()->settings());
|
||||
#endif
|
||||
connect(&d->m_consoleProcess, SIGNAL(processMessage(QString,bool)),
|
||||
this, SLOT(appendProcessMessage(QString,bool)));
|
||||
connect(&d->m_consoleProcess, SIGNAL(processError(QString)),
|
||||
this, SLOT(consoleProcessError(QString)));
|
||||
connect(&d->m_consoleProcess, SIGNAL(processStopped()),
|
||||
this, SLOT(processStopped()));
|
||||
|
||||
@@ -118,11 +118,6 @@ ApplicationLauncher::~ApplicationLauncher()
|
||||
{
|
||||
}
|
||||
|
||||
void ApplicationLauncher::appendProcessMessage(const QString &output, bool onStdErr)
|
||||
{
|
||||
emit appendMessage(output, onStdErr ? Utils::ErrorMessageFormat : Utils::NormalMessageFormat);
|
||||
}
|
||||
|
||||
void ApplicationLauncher::setWorkingDirectory(const QString &dir)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
@@ -223,6 +218,11 @@ void ApplicationLauncher::guiProcessError()
|
||||
emit processExited(d->m_guiProcess.exitCode());
|
||||
}
|
||||
|
||||
void ApplicationLauncher::consoleProcessError(const QString &error)
|
||||
{
|
||||
emit appendMessage(error + QLatin1Char('\n'), Utils::ErrorMessageFormat);
|
||||
}
|
||||
|
||||
void ApplicationLauncher::readStandardOutput()
|
||||
{
|
||||
QByteArray data = d->m_guiProcess.readAllStandardOutput();
|
||||
|
||||
@@ -78,8 +78,8 @@ signals:
|
||||
|
||||
private slots:
|
||||
void processStopped();
|
||||
void appendProcessMessage(const QString &output, bool onStdErr);
|
||||
void guiProcessError();
|
||||
void consoleProcessError(const QString &error);
|
||||
void readStandardOutput();
|
||||
void readStandardError();
|
||||
#ifdef Q_OS_WIN
|
||||
|
||||
Reference in New Issue
Block a user