aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/layouts/qquicklayout.cpp
diff options
context:
space:
mode:
authorRobin Burchell <robin.burchell@viroteck.net>2016-07-08 13:25:02 +0200
committerJani Heikkinen <jani.heikkinen@qt.io>2016-11-30 08:31:52 +0000
commit3b4f00ecb54432f514f184c251a316896a88f91a (patch)
treef39299a24451d8e7f7beb17eb314247d5481c2fc /src/imports/layouts/qquicklayout.cpp
parent39496a40748be1d60c909ba679c45c788ec6412f (diff)
Layouts: Use QQuickItemChangeListener for more things
Signal connections are expensive: even with qmlobject_connect, there's a bunch of memory allocation. By avoiding the signal connections, we can do the same thing essentially, a little faster. This gives me another 15-20 RowLayout instances per frame when testing with RowLayout containing 5 Rectangles on qmlbench (from ~139 to ~155 ops/frame). Change-Id: I4448a28128dc251e40b6b06d642bae716af212f4 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/imports/layouts/qquicklayout.cpp')
-rw-r--r--src/imports/layouts/qquicklayout.cpp32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/imports/layouts/qquicklayout.cpp b/src/imports/layouts/qquicklayout.cpp
index 07ada75a5f..3786d21727 100644
--- a/src/imports/layouts/qquicklayout.cpp
+++ b/src/imports/layouts/qquicklayout.cpp
@@ -763,18 +763,14 @@ void QQuickLayout::itemChange(ItemChange change, const ItemChangeData &value)
{
if (change == ItemChildAddedChange) {
QQuickItem *item = value.item;
- qmlobject_connect(item, QQuickItem, SIGNAL(implicitWidthChanged()), this, QQuickLayout, SLOT(invalidateSenderItem()));
- qmlobject_connect(item, QQuickItem, SIGNAL(implicitHeightChanged()), this, QQuickLayout, SLOT(invalidateSenderItem()));
qmlobject_connect(item, QQuickItem, SIGNAL(baselineOffsetChanged(qreal)), this, QQuickLayout, SLOT(invalidateSenderItem()));
- QQuickItemPrivate::get(item)->addItemChangeListener(this, QQuickItemPrivate::SiblingOrder);
+ QQuickItemPrivate::get(item)->addItemChangeListener(this, QQuickItemPrivate::SiblingOrder | QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight | QQuickItemPrivate::Destroyed | QQuickItemPrivate::Visibility);
if (isReady())
updateLayoutItems();
} else if (change == ItemChildRemovedChange) {
QQuickItem *item = value.item;
- qmlobject_disconnect(item, QQuickItem, SIGNAL(implicitWidthChanged()), this, QQuickLayout, SLOT(invalidateSenderItem()));
- qmlobject_disconnect(item, QQuickItem, SIGNAL(implicitHeightChanged()), this, QQuickLayout, SLOT(invalidateSenderItem()));
qmlobject_disconnect(item, QQuickItem, SIGNAL(baselineOffsetChanged(qreal)), this, QQuickLayout, SLOT(invalidateSenderItem()));
- QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::SiblingOrder);
+ QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::SiblingOrder | QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight | QQuickItemPrivate::Destroyed | QQuickItemPrivate::Visibility);
if (isReady())
updateLayoutItems();
}
@@ -812,6 +808,30 @@ void QQuickLayout::itemSiblingOrderChanged(QQuickItem *item)
updateLayoutItems();
}
+void QQuickLayout::itemImplicitWidthChanged(QQuickItem *item)
+{
+ if (!isReady() || item->signalsBlocked())
+ return;
+ invalidate(item);
+}
+
+void QQuickLayout::itemImplicitHeightChanged(QQuickItem *item)
+{
+ if (!isReady() || item->signalsBlocked())
+ return;
+ invalidate(item);
+}
+
+void QQuickLayout::itemDestroyed(QQuickItem *item)
+{
+ Q_UNUSED(item);
+}
+
+void QQuickLayout::itemVisibilityChanged(QQuickItem *item)
+{
+ Q_UNUSED(item);
+}
+
void QQuickLayout::rearrange(const QSizeF &/*size*/)
{
m_dirty = false;