From 368ae438496f8ea09061878d6a37985a22b15140 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Mon, 20 Aug 2012 17:50:41 +0300 Subject: [PATCH] Web UI shutdown fix. --- src/webui/httpconnection.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) 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) {