Make WebUI error non-fatal

* Do not exit the app when WebUI is failed for start.
* Print the error to stdout.

PR #19697.
Closes #19695.
Closes #19469.
This commit is contained in:
Hanabishi 2023-10-24 15:32:21 +05:00 committed by GitHub
parent 6860c0d60d
commit 35e4b35d12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 9 deletions

View file

@ -890,13 +890,17 @@ int Application::exec()
#ifndef DISABLE_WEBUI
m_webui = new WebUI(this);
#ifdef DISABLE_GUI
if (m_webui->isErrored())
QCoreApplication::exit(EXIT_FAILURE);
connect(m_webui, &WebUI::fatalError, this, []() { QCoreApplication::exit(EXIT_FAILURE); });
connect(m_webui, &WebUI::error, this, [](const QString &message) { fprintf(stderr, "%s\n", qUtf8Printable(message)); });
printf("%s", qUtf8Printable(u"\n******** %1 ********\n"_s.arg(tr("Information"))));
if (m_webui->isEnabled())
if (m_webui->isErrored())
{
const QString error = m_webui->errorMessage() + u'\n'
+ tr("To fix the error, you may need to edit the config file manually.");
fprintf(stderr, "%s\n", qUtf8Printable(error));
}
else if (m_webui->isEnabled())
{
const QHostAddress address = m_webui->hostAddress();
const QString url = u"%1://%2:%3"_s.arg((m_webui->isHttps() ? u"https"_s : u"http"_s)