From 9d7dad4a613df20363fa746f3a71cf3fa288e33d Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 5 Jul 2023 01:10:40 +0800 Subject: [PATCH] Don't unnecessarily restart Web server When related settings hasn't changed. --- src/webui/webui.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/webui/webui.cpp b/src/webui/webui.cpp index 19b7b37c1..4b325d785 100644 --- a/src/webui/webui.cpp +++ b/src/webui/webui.cpp @@ -68,6 +68,9 @@ void WebUI::configure() // http server const QString serverAddressString = pref->getWebUiAddress(); + const auto serverAddress = ((serverAddressString == u"*") || serverAddressString.isEmpty()) + ? QHostAddress::Any : QHostAddress(serverAddressString); + if (!m_httpServer) { m_webapp = new WebApplication(app(), this); @@ -75,8 +78,7 @@ void WebUI::configure() } else { - if ((m_httpServer->serverAddress().toString() != serverAddressString) - || (m_httpServer->serverPort() != port)) + if ((m_httpServer->serverAddress() != serverAddress) || (m_httpServer->serverPort() != port)) m_httpServer->close(); } @@ -103,9 +105,7 @@ void WebUI::configure() if (!m_httpServer->isListening()) { - const auto address = ((serverAddressString == u"*") || serverAddressString.isEmpty()) - ? QHostAddress::Any : QHostAddress(serverAddressString); - bool success = m_httpServer->listen(address, port); + const bool success = m_httpServer->listen(serverAddress, port); if (success) { LogMsg(tr("Web UI: Now listening on IP: %1, port: %2").arg(serverAddressString).arg(port));