java-topology/defects/krita-0001/patch/krita-0001.patch
russell@unturf.com 7ecd95c4d6 kdenlive+audacity: 5-MOAD rescan; kdenlive-0010 CWE-407 checkConsistency QList::contains O(P*K^2) 500x at K=1000; audacity CLEAN rescan confirmed
kdenlive-0010: KeyframeModelList::checkConsistency() in
src/assets/keyframes/model/keyframemodellist.cpp calls QList<GenTime>::contains()
inside nested loops — O(P*K^2) at clip load for multi-parameter keyframe effects.
Fix: std::set<GenTime> using operator< for O(log K) insert/lookup in both phases.
Speedup: 50x at K=100, 250x at K=500, 500x at K=1000 (P=3 params). 12/12 PASS.

Audacity: full 5-MOAD rescan on fresh clone confirms prior scan results.
No new defects. MOADs 0002/0003/0004/0005 CLEAN.
2026-04-03 14:50:10 -04:00

27 lines
2 KiB
Diff

--- 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);