From 80f6b146e6a1b3e7164a728271c0e17eb25c3e98 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 30 Aug 2017 15:00:39 +0200 Subject: QQuickTabBar: optimize layouting QQuickTabBarPrivate::updateLayout() was being called quite many times during the creation. This patch reduces the amount of calls significantly and gives a little boost in qmlbench too (~133 => ~140). Change-Id: I6f8b31919cdc1a5e6cf4d133c5e55e400f3f8c26 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquicktabbar.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/quicktemplates2/qquicktabbar.cpp b/src/quicktemplates2/qquicktabbar.cpp index 814d14ea..52522262 100644 --- a/src/quicktemplates2/qquicktabbar.cpp +++ b/src/quicktemplates2/qquicktabbar.cpp @@ -228,27 +228,29 @@ void QQuickTabBarPrivate::updateLayout() contentHeightChange = true; } + updatingLayout = true; if (contentWidthChange) emit q->contentWidthChanged(); if (contentHeightChange) emit q->contentHeightChanged(); + updatingLayout = false; } -void QQuickTabBarPrivate::itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) +void QQuickTabBarPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &) { - if (!updatingLayout) + if (!updatingLayout && change.sizeChange() && QQuickItemPrivate::get(item)->componentComplete) updateLayout(); } -void QQuickTabBarPrivate::itemImplicitWidthChanged(QQuickItem *) +void QQuickTabBarPrivate::itemImplicitWidthChanged(QQuickItem *item) { - if (!updatingLayout && !hasContentWidth) + if (!updatingLayout && !hasContentWidth && QQuickItemPrivate::get(item)->componentComplete) updateLayout(); } -void QQuickTabBarPrivate::itemImplicitHeightChanged(QQuickItem *) +void QQuickTabBarPrivate::itemImplicitHeightChanged(QQuickItem *item) { - if (!updatingLayout && !hasContentHeight) + if (!updatingLayout && !hasContentHeight && QQuickItemPrivate::get(item)->componentComplete) updateLayout(); } @@ -397,7 +399,10 @@ void QQuickTabBar::geometryChanged(const QRectF &newGeometry, const QRectF &oldG { Q_D(QQuickTabBar); QQuickContainer::geometryChanged(newGeometry, oldGeometry); - d->updateLayout(); + if (!d->updatingLayout) + d->updateLayout(); + else + polish(); } bool QQuickTabBar::isContent(QQuickItem *item) const -- cgit v1.2.3