From 40b2b958640bab994c3569555b302f66c6f6b65b Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 4 Feb 2020 14:25:30 +0100 Subject: [PATCH] QmlDesigner: Fix QTC_ASSERT The method setTimelineRecording() assumes a valid timeline. Change-Id: If57dac581fb14e4871745929d7f202d1e831fc40 Reviewed-by: Knud Dollereder Reviewed-by: Tim Jenssen --- .../components/timelineeditor/timelineview.cpp | 4 +++- .../components/timelineeditor/timelinewidget.cpp | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/plugins/qmldesigner/components/timelineeditor/timelineview.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelineview.cpp index eb4b270a990..61ac1aba590 100644 --- a/src/plugins/qmldesigner/components/timelineeditor/timelineview.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineview.cpp @@ -84,7 +84,9 @@ void TimelineView::modelAttached(Model *model) void TimelineView::modelAboutToBeDetached(Model *model) { m_timelineWidget->reset(); - setTimelineRecording(false); + const bool empty = getTimelines().isEmpty(); + if (!empty) + setTimelineRecording(false); AbstractView::modelAboutToBeDetached(model); } diff --git a/src/plugins/qmldesigner/components/timelineeditor/timelinewidget.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelinewidget.cpp index 7d64fad56a3..914a16b056e 100644 --- a/src/plugins/qmldesigner/components/timelineeditor/timelinewidget.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinewidget.cpp @@ -486,11 +486,15 @@ void TimelineWidget::setupScrollbar(int min, int max, int current) void TimelineWidget::setTimelineId(const QString &id) { - setTimelineActive(!m_timelineView->getTimelines().isEmpty()); - if (m_timelineView->isAttached()) { + const bool empty = m_timelineView->getTimelines().isEmpty(); + setTimelineActive(!empty); + if (m_timelineView->isAttached() && !empty) { m_toolbar->setCurrentTimeline(m_timelineView->modelNodeForId(id)); m_toolbar->setCurrentState(m_timelineView->currentState().name()); m_timelineView->setTimelineRecording(false); + } else { + m_toolbar->setCurrentTimeline({}); + m_toolbar->setCurrentState({}); } }