diff --git a/src/webui/httpconnection.cpp b/src/webui/httpconnection.cpp index 8816ebda0..72db365d6 100644 --- a/src/webui/httpconnection.cpp +++ b/src/webui/httpconnection.cpp @@ -277,9 +277,20 @@ void HttpConnection::respond() { } if (list[0] == "command") { const QString& command = list[1]; - respondCommand(command); - m_generator.setStatusLine(200, "OK"); - write(); + if (command == "shutdown") { + qDebug() << "Shutdown request from Web UI"; + // Special case handling for shutdown, we + // need to reply to the Web UI before + // actually shutting down. + m_generator.setStatusLine(200, "OK"); + write(); + // Exit application + qApp->exit(); + } else { + respondCommand(command); + m_generator.setStatusLine(200, "OK"); + write(); + } return; } } @@ -595,10 +606,6 @@ void HttpConnection::respondCommand(const QString& command) { QBtSession::instance()->recheckTorrent(m_parser.post("hash")); return; } - if (command == "shutdown") { - qDebug() << "Shutdown request from Web UI"; - qApp->exit(); - } } void HttpConnection::decreaseTorrentsPriority(const QStringList &hashes) {