UI: TrayIcon: Add checks

This commit is contained in:
Nodir Temirkhodjaev 2024-06-08 13:32:37 +03:00
parent 8b58732fa4
commit 112e6c77f1
2 changed files with 13 additions and 5 deletions

View File

@ -47,7 +47,7 @@ void updateComboBox(
{
int index = 0;
for (const QString &name : names) {
const QString iconPath = iconPaths.at(index);
const QString &iconPath = iconPaths.at(index);
c->setItemText(index, name);
c->setItemIcon(index, IconCache::icon(iconPath));

View File

@ -487,8 +487,12 @@ void TrayIcon::setupTrayMenuBlockTraffic()
int index = 0;
const QStringList iconPaths = FirewallConf::blockTrafficIconPaths();
for (const QString &name : FirewallConf::blockTrafficNames()) {
const QString iconPath = iconPaths.at(index);
const auto &iniKey = blockTrafficIniKeys[index];
const QString &iconPath = iconPaths.at(index);
if (Q_UNLIKELY(index >= std::size(blockTrafficIniKeys)))
break;
const char *iniKey = blockTrafficIniKeys[index];
QAction *a = addAction(m_blockTrafficMenu, iconPath, /*receiver=*/nullptr,
/*member=*/nullptr, ActionNone, /*checkable=*/true);
@ -520,8 +524,12 @@ void TrayIcon::setupTrayMenuFilterMode()
int index = 0;
const QStringList iconPaths = FirewallConf::filterModeIconPaths();
for (const QString &name : FirewallConf::filterModeNames()) {
const QString iconPath = iconPaths.at(index);
const auto &iniKey = filterModeIniKeys[index];
const QString &iconPath = iconPaths.at(index);
if (Q_UNLIKELY(index >= std::size(filterModeIniKeys)))
break;
const char *iniKey = filterModeIniKeys[index];
QAction *a = addAction(m_filterModeMenu, iconPath, /*receiver=*/nullptr, /*member=*/nullptr,
ActionNone, /*checkable=*/true);