From c3d22dfcd986af9ce4ff94c94518e278c8029bb4 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 5 Dec 2023 13:58:57 +0100 Subject: [PATCH] QmlDesigner: Avoid deletion and recreation of keyframes if possible Without this all keyframes are first deleted and then recreated. This becomes notable slow with a larger number of keyframes, since the timeline does react to each deletion/creation and rebuilds the scene for the group. Instead we can keep all keyframes and simply adjust their frame. Change-Id: Ic34ffbdea74f57cf8f5bcddfbce8a8c18ffef7b0 Reviewed-by: Knud Dollereder Reviewed-by: Qt CI Patch Build Bot --- .../components/curveeditor/curveeditorview.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/plugins/qmldesigner/components/curveeditor/curveeditorview.cpp b/src/plugins/qmldesigner/components/curveeditor/curveeditorview.cpp index e7395c66625..afe704a59d9 100644 --- a/src/plugins/qmldesigner/components/curveeditor/curveeditorview.cpp +++ b/src/plugins/qmldesigner/components/curveeditor/curveeditorview.cpp @@ -307,10 +307,20 @@ void CurveEditorView::commitKeyframes(TreeItem *item) auto replaceKeyframes = [&group, pitem, this]() mutable { m_block = true; - for (auto& frame : group.keyframes()) - frame.destroy(); - AnimationCurve curve = pitem->curve(); + + unsigned int i = 0; + const size_t numberOfKeyFrames = curve.keyframes().size(); + for (auto &frame : group.keyframes()) { + if (i < numberOfKeyFrames) { + QPointF pos = curve.keyframes().at(i).position(); + frame.variantProperty("frame").setValue(pos.x()); + } else { + frame.destroy(); + } + i++; + } + if (curve.valueType() == AnimationCurve::ValueType::Bool) { for (const auto& frame : curve.keyframes()) { QPointF pos = frame.position();