From 9a6157becd33bdaaeb663605d4daf27667eb65be Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Mon, 14 Oct 2019 17:06:30 +0200 Subject: [PATCH] QmlDesigner: Fix crash There is no guarantee that the timeline is valid at this point. Change-Id: I48a31b1f4c305c4764d8bebee9de16e51aec4a47 Reviewed-by: Mahmoud Badri Reviewed-by: Thomas Hartmann --- .../timelineeditor/timelinegraphicsscene.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/qmldesigner/components/timelineeditor/timelinegraphicsscene.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelinegraphicsscene.cpp index 576717228d2..6c252562493 100644 --- a/src/plugins/qmldesigner/components/timelineeditor/timelinegraphicsscene.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinegraphicsscene.cpp @@ -174,11 +174,13 @@ void TimelineGraphicsScene::invalidateLayout() void TimelineGraphicsScene::updateKeyframePositionsCache() { - auto kfPos = keyframePositions(); - std::sort(kfPos.begin(), kfPos.end()); - kfPos.erase(std::unique(kfPos.begin(), kfPos.end()), kfPos.end()); // remove duplicates + if (currentTimeline().isValid()) { + auto kfPos = keyframePositions(); + std::sort(kfPos.begin(), kfPos.end()); + kfPos.erase(std::unique(kfPos.begin(), kfPos.end()), kfPos.end()); // remove duplicates - m_keyframePositionsCache = kfPos; + m_keyframePositionsCache = kfPos; + } } // snap a frame to nearest keyframe or ruler tick