Mercurial > hg > easyhg
changeset 189:6bb510abe4f1
* Handle failure to start processes at all (e.g. because executable path is wrong)
author | Chris Cannam |
---|---|
date | Mon, 20 Dec 2010 16:47:00 +0000 |
parents | 07b908b4fa5f |
children | f4d261fa3a99 |
files | hgrunner.cpp hgrunner.h mainwindow.cpp |
diffstat | 3 files changed, 14 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/hgrunner.cpp Mon Dec 20 16:15:43 2010 +0000 +++ b/hgrunner.cpp Mon Dec 20 16:47:00 2010 +0000 @@ -68,8 +68,9 @@ // If we haven't unbundled an extension, always do that (so that // it's available in case someone wants to use it later, e.g. to // fix a malfunctioning setup). But the path we actually prefer - // is the one in the settings first; then the unbundled one; then - // anything in the path if for some reason unbundling failed + // is the one in the settings first, if it exists; then the + // unbundled one; then anything in the path if for some reason + // unbundling failed QSettings settings; settings.beginGroup("Locations"); @@ -80,7 +81,7 @@ } QString extpath = settings.value("extensionpath", "").toString(); - if (extpath != "") return extpath; + if (extpath != "" && QFile(extpath).exists()) return extpath; extpath = unbundled; if (extpath == "") { @@ -330,6 +331,11 @@ } } +void HgRunner::error(QProcess::ProcessError) +{ + finished(-1, QProcess::CrashExit); +} + void HgRunner::finished(int procExitCode, QProcess::ExitStatus procExitStatus) { // Save the current action and reset m_currentAction before we @@ -343,7 +349,7 @@ m_currentAction = HgAction(); closeProcInput(); - delete m_proc; + m_proc->deleteLater(); m_proc = 0; if (completedAction.action == ACT_NONE) { @@ -446,6 +452,8 @@ m_proc->setProcessEnvironment(env); connect(m_proc, SIGNAL(started()), this, SLOT(started())); + connect(m_proc, SIGNAL(error(QProcess::ProcessError)), + this, SLOT(error(QProcess::ProcessError))); connect(m_proc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(finished(int, QProcess::ExitStatus))); connect(m_proc, SIGNAL(readyReadStandardOutput()),
--- a/hgrunner.h Mon Dec 20 16:15:43 2010 +0000 +++ b/hgrunner.h Mon Dec 20 16:47:00 2010 +0000 @@ -45,6 +45,7 @@ private slots: void started(); + void error(QProcess::ProcessError); void finished(int procExitCode, QProcess::ExitStatus procExitStatus); void dataReadyStdout(); void dataReadyStderr();
--- a/mainwindow.cpp Mon Dec 20 16:15:43 2010 +0000 +++ b/mainwindow.cpp Mon Dec 20 16:47:00 2010 +0000 @@ -1398,7 +1398,7 @@ QMessageBox::warning (this, tr("Failed to run Mercurial"), format3(tr("Failed to run Mercurial"), - tr("The Mercurial program either could not be found or failed to run.<br>This may indicate a problem with the Mercurial installation, or with the EasyHg interaction extension.<br><br>The test command said:"), + tr("The Mercurial program either could not be found or failed to run.<br>This may indicate a problem with the Mercurial installation, or with the EasyHg interaction extension.<br><br>%1").arg(output == "" ? QString("") : tr("The test command said:")), output)); settings(); return;