fix: Handle empty layout names and language codes in layout parser
This commit is contained in:
parent
6e9694b5d8
commit
d6087cc5bd
1 changed files with 10 additions and 0 deletions
|
|
@ -114,6 +114,11 @@ void X11LayoutsParser::convertLayoutToISO639_2(
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < layoutNames.size(); i++) {
|
for (size_t i = 0; i < layoutNames.size(); i++) {
|
||||||
const auto &layoutName = layoutNames[i];
|
const auto &layoutName = layoutNames[i];
|
||||||
|
if (layoutNames[i].empty()) {
|
||||||
|
LOG((CLOG_DEBUG "skip converting empty layout name"));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
auto langIter =
|
auto langIter =
|
||||||
std::find_if(allLang.begin(), allLang.end(), [&layoutName](const Lang &l) { return l.name == layoutName; });
|
std::find_if(allLang.begin(), allLang.end(), [&layoutName](const Lang &l) { return l.name == layoutName; });
|
||||||
if (langIter == allLang.end()) {
|
if (langIter == allLang.end()) {
|
||||||
|
|
@ -174,6 +179,11 @@ std::string X11LayoutsParser::convertLayotToISO(
|
||||||
const std::string &pathToEvdevFile, const std::string &layoutLangCode, bool needToReloadFiles
|
const std::string &pathToEvdevFile, const std::string &layoutLangCode, bool needToReloadFiles
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
if (layoutLangCode.empty()) {
|
||||||
|
LOG((CLOG_DEBUG "skip converting empty layout lang code"));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string> iso639_2Codes;
|
std::vector<std::string> iso639_2Codes;
|
||||||
convertLayoutToISO639_2(pathToEvdevFile, needToReloadFiles, {layoutLangCode}, {""}, iso639_2Codes);
|
convertLayoutToISO639_2(pathToEvdevFile, needToReloadFiles, {layoutLangCode}, {""}, iso639_2Codes);
|
||||||
if (iso639_2Codes.empty()) {
|
if (iso639_2Codes.empty()) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue