From b12a1915a1dbcfc2649820fe7631e5aa0262a790 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 5 Jan 2017 16:28:36 +0100 Subject: [PATCH] QmlDesigner: Fixing regression for id renaming When we rename an id we actually trigger a refactoring operation on the qml text. Due to recent changes we delay and compress qml changes from the text side using a 400ms timer. This is fatal for renaming ids. When we trigger refactoring operations on the text we have to ensure the update is done instantly without delay. To ensure this we use the memeber m_instantQmlTextUpdate. Change-Id: Ie007ee99f201cd444033c38630d7e7a9f5a673b5 Reviewed-by: Tim Jenssen --- .../designercore/include/rewriterview.h | 1 + .../designercore/model/rewriterview.cpp | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmldesigner/designercore/include/rewriterview.h b/src/plugins/qmldesigner/designercore/include/rewriterview.h index 251bbf92b85..d8ea075273f 100644 --- a/src/plugins/qmldesigner/designercore/include/rewriterview.h +++ b/src/plugins/qmldesigner/designercore/include/rewriterview.h @@ -189,6 +189,7 @@ private: //variables QString m_rewritingErrorMessage; QString m_lastCorrectQmlSource; QTimer m_amendTimer; + bool m_instantQmlTextUpdate = false; }; } //QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/model/rewriterview.cpp b/src/plugins/qmldesigner/designercore/model/rewriterview.cpp index 8d6ba3ecc84..5cc829c528d 100644 --- a/src/plugins/qmldesigner/designercore/model/rewriterview.cpp +++ b/src/plugins/qmldesigner/designercore/model/rewriterview.cpp @@ -573,8 +573,13 @@ bool RewriterView::renameId(const QString& oldId, const QString& newId) && rootModelNode().hasBindingProperty(propertyName) && rootModelNode().bindingProperty(propertyName).isAliasExport(); + bool instant = m_instantQmlTextUpdate; + m_instantQmlTextUpdate = true; + bool refactoring = textModifier()->renameId(oldId, newId); + m_instantQmlTextUpdate = instant; + if (refactoring && hasAliasExport) { //Keep export alias properties rootModelNode().removeProperty(propertyName); PropertyName newPropertyName = newId.toUtf8(); @@ -675,7 +680,12 @@ void RewriterView::moveToComponent(const ModelNode &modelNode) { int offset = nodeOffset(modelNode); + bool instant = m_instantQmlTextUpdate; + m_instantQmlTextUpdate = true; + textModifier()->moveToComponent(offset); + + m_instantQmlTextUpdate = instant; } QStringList RewriterView::autoComplete(const QString &text, int pos, bool explicitComplete) @@ -736,7 +746,10 @@ void RewriterView::qmlTextChanged() } case Amend: { - m_amendTimer.start(400); + if (m_instantQmlTextUpdate) + amendQmlText(); + else + m_amendTimer.start(400); break; } }