From 279454a54ba89b354a26598abb311c2b44250428 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 2 Jun 2020 12:11:43 +0300 Subject: [PATCH] QmlDesigner: Keep hasActiveTimeline QML context property up to date Change hasActiveTimeline QML context property setting to be based on current timeline change notifications instead of timeline node creation, as the timeline will not be valid at the time of the node creation. That also failed to detect timeline deletion. Also fixed the timeline logic to clear current timeline from model when the timeline is deleted. Change-Id: I9191300c964bc624a958003b6aa0d5d9e77ddf9a Fixes: QDS-2139 Reviewed-by: Thomas Hartmann --- .../components/propertyeditor/propertyeditorview.cpp | 7 ++----- .../components/propertyeditor/propertyeditorview.h | 2 +- .../qmldesigner/components/timelineeditor/timelineview.cpp | 4 +--- .../components/timelineeditor/timelinewidget.cpp | 2 +- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp index fbfc017d40b..f4c612aad8b 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp @@ -357,12 +357,9 @@ bool PropertyEditorView::locked() const return m_locked; } -void PropertyEditorView::nodeCreated(const ModelNode &modelNode) +void PropertyEditorView::currentTimelineChanged(const ModelNode &) { - if (!m_qmlBackEndForCurrentType->contextObject()->hasActiveTimeline() - && QmlTimeline::isValidQmlTimeline(modelNode)) { - m_qmlBackEndForCurrentType->contextObject()->setHasActiveTimeline(QmlTimeline::hasActiveTimeline(this)); - } + m_qmlBackEndForCurrentType->contextObject()->setHasActiveTimeline(QmlTimeline::hasActiveTimeline(this)); } void PropertyEditorView::updateSize() diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.h index 5602ccd8245..c6dd85d98f8 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.h +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.h @@ -94,7 +94,7 @@ public: bool locked() const; - void nodeCreated(const ModelNode &createdNode) override; + void currentTimelineChanged(const ModelNode &node) override; protected: void timerEvent(QTimerEvent *event) override; diff --git a/src/plugins/qmldesigner/components/timelineeditor/timelineview.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelineview.cpp index 61ac1aba590..1ba0d603420 100644 --- a/src/plugins/qmldesigner/components/timelineeditor/timelineview.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineview.cpp @@ -386,9 +386,7 @@ void TimelineView::setTimelineRecording(bool value) { ModelNode node = widget()->graphicsScene()->currentTimeline(); - QTC_ASSERT(node.isValid(), return ); - - if (value) { + if (value && node.isValid()) { activateTimelineRecording(node); } else { deactivateTimelineRecording(); diff --git a/src/plugins/qmldesigner/components/timelineeditor/timelinewidget.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelinewidget.cpp index d399eb19527..ed727dc4cce 100644 --- a/src/plugins/qmldesigner/components/timelineeditor/timelinewidget.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinewidget.cpp @@ -563,11 +563,11 @@ void TimelineWidget::setTimelineId(const QString &id) 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({}); } + m_timelineView->setTimelineRecording(false); } void TimelineWidget::setTimelineActive(bool b)