Merge pull request #3907 from offhub/fix013

Update NewBoxWizard.cpp
This commit is contained in:
DavidXanatos 2024-05-18 09:27:26 +02:00 committed by GitHub
commit ade6a497d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 9 deletions

View File

@ -144,10 +144,10 @@ SB_STATUS CNewBoxWizard::TryToCreateBox()
}
if (removeDefaultAll) {
for (const QString& bLine : boxSettingsLines) {
QStringList bParts = bLine.split("=", Qt::SkipEmptyParts);
if (bParts.size() == 2) {
QString bKey = bParts[0].trimmed();
QString bValue = bParts[1].trimmed();
int bParts = bLine.indexOf("=", Qt::SkipEmptyParts);
if (bParts != -1) {
QString bKey = bLine.mid(0, bParts).trimmed();
QString bValue = bLine.mid(bParts + 1).trimmed();
if (bKey.compare(ENABLED_PREFIX, Qt::CaseInsensitive) != 0 && bKey.compare(CFGLVL_PREFIX) != 0) { // Do not remove Enabled and ConfigLevel
pBox->DelValue(bKey, bValue);
}
@ -165,12 +165,12 @@ SB_STATUS CNewBoxWizard::TryToCreateBox()
}
else if (sharedTemplateMode == 2) { // Append to config
for (const QString& tLine : templateSettings.split("\n", Qt::SkipEmptyParts)) {
QStringList tParts = tLine.split("=", Qt::SkipEmptyParts);
if (tParts.size() != 2) {
continue; // Skip lines that don't have exactly one '=' character
int tParts = tLine.indexOf("=", Qt::SkipEmptyParts);
if (tParts == -1) {
continue; // Skip lines that don't have at least one '=' character.
}
QString tKey = tParts[0].trimmed();
QString tValue = tParts[1].trimmed();
QString tKey = tLine.mid(0, tParts).trimmed();
QString tValue = tLine.mid(tParts + 1).trimmed();
if (tKey.compare(ENABLED_PREFIX, Qt::CaseInsensitive) == 0 || tKey.startsWith(TMPL_PREFIX) || tKey.startsWith("#") || tKey.endsWith(BOX_DISABLED_SUFFIX)) {
continue; // Skip lines that start or end with one of these