aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktext.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-04-12 09:51:25 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2017-04-25 20:12:49 +0000
commit3390cc0274b7f71fec1e627017e24cd82904ab0b (patch)
tree2a65cc4b319c70ab8d69e1990c1771643447f692 /src/quick/items/qquicktext.cpp
parent1a3dd2031a8151bf9d50d070840fb664f7fd5d44 (diff)
QQuickText: apply updateSize() optimization for item change listeners
QQuickTextPrivate::updateSize() emits implicitWidthChanged() and implicitHeightChanged() to see if anything is connected to the signals and therefore calls getImplicitWidth() or getImplicitHeight(), which again call updateSize() recursively. This way it can detect the recursion and avoid doing the size calculation multiple times. The problem with emitting the change notifier signals directly is that item change listeners (QQuickItemChangeListener) do not get notified. Item change listeners are commonly used by Qt Quick Layouts and Qt Quick Controls 2. By calling QQuickItemPrivate::implicitWidthChanged() and implicitHeightChanged() the item change listeners are also called in addition to emitting the change notifier signals. Results from qmlbench delegates_buttoncontrol2.qml run with the very latest dev-branch of qtquickcontrols2: Before: Average: 130.2 frames; using samples; MedianAll=130; StdDev=1.92354, CoV=0.0147737 After: Average: 139.4 frames; using samples; MedianAll=140; StdDev=0.894427, CoV=0.00641626 Task-number: QTBUG-59746 Change-Id: I4461cdf8ddc25f80a38756a1e2b5e3d7d1e84791 Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
Diffstat (limited to 'src/quick/items/qquicktext.cpp')
-rw-r--r--src/quick/items/qquicktext.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index c8bc76aef8..19b99fbea2 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -359,8 +359,8 @@ void QQuickTextPrivate::updateSize()
}
if (!requireImplicitSize) {
- emit q->implicitWidthChanged();
- emit q->implicitHeightChanged();
+ implicitWidthChanged();
+ implicitHeightChanged();
// if the implicitWidth is used, then updateSize() has already been called (recursively)
if (requireImplicitSize)
return;