From 85f3472b224dc09ae47b8b6ae2e953f611a71812 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 6 May 2010 15:37:08 +0200 Subject: [PATCH] QuickDesigner: Reduce numbers of redraws / state switching in States Editor nodeInstancePropertyChanged() is called for _every_ state switch ... so the current assumption that it only reflects real changes does not hold. Instead, use the orphaned sceneChanged() method to schedule redraws. However, this still results in some overhead when switching to the base state (sceneChanged() cannot decide whether it has to redraw all other states or not). Reviewed-by: Christiaan Janssen --- .../stateseditor/stateseditorview.cpp | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp index 6b0834fed7d..7fab5946693 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp @@ -339,16 +339,11 @@ void StatesEditorView::nodeOrderChanged(const NodeListProperty &listProperty, co void StatesEditorView::nodeInstancePropertyChanged(const ModelNode &node, const QString &propertyName) { - if (!m_settingSilentState) { - if (QmlModelState(node).isValid()) { - startUpdateTimer(modelStateIndex(node) + 1, 0); - } else { //a change to the base state update all - for (int i = 0; i < m_modelStates.count(); ++i) - startUpdateTimer(i, 0); - } - } - + // sets currentState() used in sceneChanged QmlModelView::nodeInstancePropertyChanged(node, propertyName); + + if (!m_settingSilentState) + sceneChanged(); } void StatesEditorView::stateChanged(const QmlModelState &newQmlModelState, const QmlModelState &oldQmlModelState) @@ -456,8 +451,11 @@ void StatesEditorView::sceneChanged() if (debug) qDebug() << __FUNCTION__; - // If we are in base state we have to update the pixmaps of all states - // otherwise only the pixmpap for the current state + // If we are in base state we have to update the pixmaps of all states, + // otherwise only the pixmap for the current state + + // TODO: Since a switch to the base state also results in nodePropertyChanged and + // therefore sceneChanged calls, we're rendering too much here if (currentState().isValid()) { //during setup we might get sceneChanged signals with an invalid currentState() if (currentState().isBaseState()) {