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