# HG changeset patch # User Chris Cannam # Date 1330448365 0 # Node ID 39cac58b4f9283e6ba048ae47c9d5f431ed52e21 # Parent 0a094020c2d4263d92047c7385357771ba03ee22 Add commandCancelled signal -- but don't make use of it; it didn't work out as I'd hoped diff -r 0a094020c2d4 -r 39cac58b4f92 src/hgrunner.cpp --- a/src/hgrunner.cpp Tue Feb 28 14:38:42 2012 +0000 +++ b/src/hgrunner.cpp Tue Feb 28 16:59:25 2012 +0000 @@ -339,9 +339,9 @@ void HgRunner::finished(int procExitCode, QProcess::ExitStatus procExitStatus) { - if (!m_proc) return; + if (!m_proc) return; - // Save the current action and reset m_currentAction before we + // Save the current action and reset m_currentAction before we // emit a signal to mark the completion; otherwise we may be // resetting the action after a slot has already tried to set it // to something else to start a new action @@ -377,8 +377,10 @@ void HgRunner::killCurrentActions() { + HgAction current = m_currentAction; m_queue.clear(); killCurrentCommand(); + emit commandCancelled(current); } void HgRunner::killCurrentCommand() diff -r 0a094020c2d4 -r 39cac58b4f92 src/hgrunner.h --- a/src/hgrunner.h Tue Feb 28 14:38:42 2012 +0000 +++ b/src/hgrunner.h Tue Feb 28 16:59:25 2012 +0000 @@ -46,6 +46,13 @@ void commandCompleted(HgAction action, QString stdOut); void commandFailed(HgAction action, QString stdErr, QString stdOut); + /** + * Emitted when the currently executing command is cancelled. Note + * that this clears the queue completely, so all subsequent + * commands are also discarded. + */ + void commandCancelled(HgAction action); + private slots: void started(); void error(QProcess::ProcessError); diff -r 0a094020c2d4 -r 39cac58b4f92 src/mainwindow.cpp --- a/src/mainwindow.cpp Tue Feb 28 14:38:42 2012 +0000 +++ b/src/mainwindow.cpp Tue Feb 28 16:59:25 2012 +0000 @@ -85,6 +85,8 @@ this, SLOT(commandCompleted(HgAction, QString))); connect(m_runner, SIGNAL(commandFailed(HgAction, QString, QString)), this, SLOT(commandFailed(HgAction, QString, QString))); + connect(m_runner, SIGNAL(commandCancelled(HgAction)), + this, SLOT(commandCancelled(HgAction))); statusBar()->addPermanentWidget(m_runner); setWindowTitle(tr("EasyMercurial")); @@ -2528,6 +2530,19 @@ } } +void MainWindow::commandCancelled(HgAction cancelledAction) +{ + // Originally I had this checking whether the cancelled action was + // a network one and, if so, calling hgQueryPaths to update the + // local view in case it had changed anything. But that doesn't + // work properly -- because at this point, although the command + // has been cancelled and a kill signal sent, it hasn't actually + // exited yet. If we request another command now, it will go on + // the stack and be associated with the failed exit forthcoming + // from the cancelled command -- giving the user a disturbing + // command-failed dialog +} + void MainWindow::connectActions() { connect(m_exitAct, SIGNAL(triggered()), this, SLOT(close())); diff -r 0a094020c2d4 -r 39cac58b4f92 src/mainwindow.h --- a/src/mainwindow.h Tue Feb 28 14:38:42 2012 +0000 +++ b/src/mainwindow.h Tue Feb 28 16:59:25 2012 +0000 @@ -54,6 +54,7 @@ void commandStarting(HgAction); void commandCompleted(HgAction action, QString stdOut); void commandFailed(HgAction action, QString stdErr, QString stdOut); + void commandCancelled(HgAction action); void enableDisableActions(); private slots: