From 9c62916c2adcf43968fff3cce590f3eac3226433 Mon Sep 17 00:00:00 2001 From: Wang Yu Date: Mon, 11 Nov 2024 16:40:53 +0800 Subject: [PATCH] Add null check in list option prettify - Add null check when processing list sub-values to prevent processing invalid items --- src/lib/configwidgetslib/optionwidget.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/configwidgetslib/optionwidget.cpp b/src/lib/configwidgetslib/optionwidget.cpp index 5f8463a..54a355c 100644 --- a/src/lib/configwidgetslib/optionwidget.cpp +++ b/src/lib/configwidgetslib/optionwidget.cpp @@ -646,7 +646,6 @@ QString OptionWidget::prettify(const fcitx::FcitxQtConfigOption &option, } return enumMap.value(value.toString()); } else if (option.type().startsWith("List|")) { - int i = 0; QStringList strs; strs.clear(); @@ -654,6 +653,9 @@ QString OptionWidget::prettify(const fcitx::FcitxQtConfigOption &option, subOption.setType(option.type().mid(5)); // Remove List| while (true) { auto subValue = readVariant(value, QString::number(i)); + if (subValue.isNull()) { + break; + } strs << prettify(subOption, subValue); i++; }