java-topology/defects/krita-0001/patch/krita-0001.patch

28 lines
2 KiB
Diff

# UNDF: UNDF-2026-000001216
--- a/plugins/dockers/layerdocker/NodeDelegate.h
+++ b/plugins/dockers/layerdocker/NodeDelegate.h
@@ -71,7 +71,7 @@ private:
void toggleProperty(KisBaseNode::PropertyList &props, const OptionalProperty clickedProperty, const Qt::KeyboardModifiers modifier, const QModelIndex &index);
- void togglePropertyRecursive(const QModelIndex &root, const OptionalProperty &clickedProperty, const QList<QModelIndex> &items, StasisOperation record, bool mode);
+ void togglePropertyRecursive(const QModelIndex &root, const OptionalProperty &clickedProperty, const QSet<QModelIndex> &items, StasisOperation record, bool mode);
bool stasisIsDirty(const QModelIndex &root, const OptionalProperty &clickedProperty, bool on = false, bool off = false);
--- a/plugins/dockers/layerdocker/NodeDelegate.cpp
+++ b/plugins/dockers/layerdocker/NodeDelegate.cpp
@@ -548,7 +548,10 @@ void NodeDelegate::Private::toggleProperty(KisBaseNode::PropertyList &props, con
getParentsIndex(items, index);
getChildrenIndex(items, index);
}
- togglePropertyRecursive(root, clickedProperty, items, record, mode);
+ // Convert to QSet for O(1) membership test in togglePropertyRecursive.
+ // QList::contains is O(N); with N layers and N items this is O(N^2) per click.
+ QSet<QModelIndex> itemsSet(items.begin(), items.end());
+ togglePropertyRecursive(root, clickedProperty, itemsSet, record, mode);
} else {
@@ -576,7 +579,7 @@ void NodeDelegate::Private::toggleProperty(KisBaseNode::PropertyList &props, con
}
-void NodeDelegate::Private::togglePropertyRecursive(const QModelIndex &root, const OptionalProperty &clickedProperty, const QList<QModelIndex> &items, StasisOperation record, bool mode)
+void NodeDelegate::Private::togglePropertyRecursive(const QModelIndex &root, const OptionalProperty &clickedProperty, const QSet<QModelIndex> &items, StasisOperation record, bool mode)
{
int rowCount = view->model()->rowCount(root);