Skip to content

Commit

Permalink
Add null check in list option prettify (#86)
Browse files Browse the repository at this point in the history
- Add null check when processing list sub-values to prevent processing invalid items
  • Loading branch information
wyu71 authored Nov 22, 2024
1 parent 09eb335 commit a783ae6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib/configwidgetslib/optionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,14 +646,16 @@ 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();
auto subOption = 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++;
}
Expand Down

0 comments on commit a783ae6

Please sign in to comment.