[utilities/kdebugsettings] src: Fix logic and variable name
Laurent Montel <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 4a798abbca5264dd52a856f625d90f2b9ed07e9f by Laurent Montel.
Committed on 17/08/2026 at 09:34.
Pushed by mlaurent into branch 'master'.
Fix logic and variable name
M +6 -5 src/core/model/customloggingcategorymodel.cpp
M +1 -1 src/widgets/customdebuglistview.cpp
https://invent.kde.org/utilities/kdebugsettings/-/commit/4a798abbca5264dd52a856f625d90f2b9ed07e9f
diff --git a/src/core/model/customloggingcategorymodel.cpp b/src/core/model/customloggingcategorymodel.cpp
index 9d2d7380..b34743f0 100644
--- a/src/core/model/customloggingcategorymodel.cpp
+++ b/src/core/model/customloggingcategorymodel.cpp
@@ -152,12 +152,14 @@ void CustomLoggingCategoryModel::addCategory(const QString &categoryName, bool e
category.categoryName = categoryName;
category.enabled = enabled;
category.loggingType = type;
- if (addCategory(category)) { }
+ if (!addCategory(category)) {
+ qCDebug(KDEBUGSETTINGSCORE_LOG) << " categorie already exist";
+ }
}
bool CustomLoggingCategoryModel::addCategory(const LoggingCategory &category)
{
- bool found = false;
+ bool added = false;
if (category.isValid()) {
auto it = std::find_if(mLoggingCategories.cbegin(), mLoggingCategories.cend(), [category](const LoggingCategory &cat) {
return cat == category;
@@ -166,11 +168,10 @@ bool CustomLoggingCategoryModel::addCategory(const LoggingCategory &category)
beginInsertRows(QModelIndex(), mLoggingCategories.count(), mLoggingCategories.count());
mLoggingCategories.append(category);
endInsertRows();
- } else {
- found = true;
+ added = true;
}
}
- return found;
+ return added;
}
LoggingCategory::List CustomLoggingCategoryModel::loggingCategories() const
diff --git a/src/widgets/customdebuglistview.cpp b/src/widgets/customdebuglistview.cpp
index f79dd3ff..11239e6f 100644
--- a/src/widgets/customdebuglistview.cpp
+++ b/src/widgets/customdebuglistview.cpp
@@ -129,7 +129,7 @@ void CustomDebugListView::slotAddRule()
if (dlg->exec()) {
const QString ruleStr = dlg->rule();
const LoggingCategory cat = KDebugSettingsUtil::convertRuleStrToLoggingCategory(ruleStr);
- if (mCustomLoggingCategoryModel->addCategory(cat)) {
+ if (!mCustomLoggingCategoryModel->addCategory(cat)) {
qCDebug(KDEBUGSETTINGS_LOG) << " categorie already exist";
}
}