From b25f083433e2e9ee568266040565bf4cbaa4e71f Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Sun, 18 Jan 2026 09:23:50 -0500 Subject: [PATCH] refactor: use Settings::value().toString().isEmpty() to check for empty setting values. This is because QVariant::isNull() no longer returns the internal types isNull() method. As a results "" is a non Null QVariant --- src/lib/common/I18N.cpp | 2 +- src/lib/common/Settings.cpp | 2 +- src/lib/gui/MainWindow.cpp | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/common/I18N.cpp b/src/lib/common/I18N.cpp index a60bca666..65c614438 100644 --- a/src/lib/common/I18N.cpp +++ b/src/lib/common/I18N.cpp @@ -82,7 +82,7 @@ I18N::I18N(QObject *parent) : QObject{parent} static const auto s_prefix = QStringLiteral("_"); - if (Settings::value(Settings::Core::Language).isNull()) { + if (Settings::value(Settings::Core::Language).toString().isEmpty()) { auto appTranslator = new QTranslator(this); if (appTranslator->load(QLocale(), kAppId, s_prefix, m_appTrPath)) { m_currentTranslations.append(appTranslator); diff --git a/src/lib/common/Settings.cpp b/src/lib/common/Settings.cpp index c32f3e44b..cfddabacd 100644 --- a/src/lib/common/Settings.cpp +++ b/src/lib/common/Settings.cpp @@ -110,7 +110,7 @@ void Settings::cleanStateSettings() void Settings::setupScreenName() { - if (m_settings->value(Settings::Core::ScreenName).isNull()) + if (m_settings->value(Settings::Core::ScreenName).toString().isEmpty()) m_settings->setValue(Settings::Core::ScreenName, cleanScreenName(QSysInfo::machineHostName())); } diff --git a/src/lib/gui/MainWindow.cpp b/src/lib/gui/MainWindow.cpp index 786ad3bb5..42c9da58a 100644 --- a/src/lib/gui/MainWindow.cpp +++ b/src/lib/gui/MainWindow.cpp @@ -429,7 +429,7 @@ void MainWindow::coreProcessError(CoreProcess::Error error) void MainWindow::startCore() { // Save current IP state when server starts - if (m_coreProcess.mode() == CoreMode::Server && Settings::value(Settings::Core::Interface).isNull()) { + if (m_coreProcess.mode() == CoreMode::Server && Settings::value(Settings::Core::Interface).toString().isEmpty()) { m_serverStartIPs = m_networkMonitor->getAvailableIPv4Addresses(); m_serverStartSuggestedIP = m_serverStartIPs.isEmpty() ? "" : m_serverStartIPs.first(); } @@ -702,8 +702,8 @@ void MainWindow::setupTrayIcon() void MainWindow::applyConfig() { - if (!Settings::value(Settings::Client::RemoteHost).isNull()) - ui->lineHostname->setText(Settings::value(Settings::Client::RemoteHost).toString()); + if (const auto host = Settings::value(Settings::Client::RemoteHost).toString(); !host.isEmpty()) + ui->lineHostname->setText(host); updateLocalFingerprint(); setTrayIcon(); @@ -1255,7 +1255,7 @@ void MainWindow::updateIpLabel(const QStringList &addresses) static const auto colorText = QStringLiteral(R"(%2)"); const bool serverStarted = m_coreProcess.isStarted(); - const bool fixedIP = !Settings::value(Settings::Core::Interface).isNull(); + const bool fixedIP = !Settings::value(Settings::Core::Interface).toString().isEmpty(); if (!fixedIP && addresses.isEmpty() && !serverStarted || (serverStarted && m_serverStartSuggestedIP.isEmpty())) { ui->lblIpAddresses->setText(colorText.arg(palette().linkVisited().color().name(), tr("No IP Detected")));