[VisualDatabase] Use scoped QSignalBlockers for filter updates (#7641)

* [VisualDatabase] Use scoped QSignalBlockers for filter updates

updateFilterModel() blocked signals on the filter model and its filter tree,\nthen unblocked each of them twice. The second pair was a no-op only because\nthe first pair had already restored the default. Use two scoped\nQSignalBlockers instead, so the models are unblocked exactly once before the\nexplicit changed()/layoutChanged() notifications.\n\nVerification: cockatrice built.

* Drop stale typo note from QSignalBlocker comment

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL
2026-10-23 10:33:29 +02:00
committed by GitHub
parent c4c7cc0253
commit e666a4978d

View File

@@ -16,6 +16,7 @@
#include <QPersistentModelIndex>
#include <QPushButton>
#include <QSharedPointer>
#include <QSignalBlocker>
#include <QStringList>
#include <QTimer>
#include <QVBoxLayout>
@@ -139,20 +140,19 @@ void VisualDatabaseDisplayNameFilterWidget::updateFilterModel()
emit filterModel->layoutAboutToBeChanged();
filterModel->clearFiltersOfType(CardFilter::Attr::AttrNameExact);
filterModel->blockSignals(true);
filterModel->filterTree()->blockSignals(true);
{
// Scope the blockers so both models are unblocked before the explicit
// change notifications below.
const QSignalBlocker modelBlocker(filterModel);
const QSignalBlocker treeBlocker(filterModel->filterTree());
for (const auto &name : activeFilters.keys()) {
QString nameString = name;
filterModel->addFilter(new CardFilter(nameString, CardFilter::Type::TypeOr, CardFilter::Attr::AttrNameExact));
for (const auto &name : activeFilters.keys()) {
QString nameString = name;
filterModel->addFilter(
new CardFilter(nameString, CardFilter::Type::TypeOr, CardFilter::Attr::AttrNameExact));
}
}
filterModel->blockSignals(false);
filterModel->filterTree()->blockSignals(false);
filterModel->blockSignals(false);
filterModel->filterTree()->blockSignals(false);
emit filterModel->filterTree()->changed();
emit filterModel->layoutChanged();
}