QmlDesigner: Fix QTC_ASSERT

The method setTimelineRecording() assumes a valid timeline.

Change-Id: If57dac581fb14e4871745929d7f202d1e831fc40
Reviewed-by: Knud Dollereder <knud.dollereder@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Thomas Hartmann
2020-02-04 14:25:30 +01:00
parent e68e7f723e
commit 40b2b95864
2 changed files with 9 additions and 3 deletions

View File

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

View File

@@ -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({});
}
}