aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-08-30 15:00:39 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2017-09-01 12:56:17 +0000
commit80f6b146e6a1b3e7164a728271c0e17eb25c3e98 (patch)
tree8d437ecf5b4ba79f640ecf89e49f5d47612427a7 /src
parent6dbc3715b9a496b91743d6ca3727178897d2af7e (diff)
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 <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/quicktemplates2/qquicktabbar.cpp19
1 files changed, 12 insertions, 7 deletions
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