From 3b4f00ecb54432f514f184c251a316896a88f91a Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Fri, 8 Jul 2016 13:25:02 +0200 Subject: Layouts: Use QQuickItemChangeListener for more things MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/imports/layouts/qquicklinearlayout_p.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/imports/layouts/qquicklinearlayout_p.h') diff --git a/src/imports/layouts/qquicklinearlayout_p.h b/src/imports/layouts/qquicklinearlayout_p.h index 86404f8d79..c289416540 100644 --- a/src/imports/layouts/qquicklinearlayout_p.h +++ b/src/imports/layouts/qquicklinearlayout_p.h @@ -77,6 +77,10 @@ public: Qt::LayoutDirection effectiveLayoutDirection() const; void setAlignment(QQuickItem *item, Qt::Alignment align) Q_DECL_OVERRIDE; + /* QQuickItemChangeListener */ + void itemDestroyed(QQuickItem *item) Q_DECL_OVERRIDE; + void itemVisibilityChanged(QQuickItem *item) Q_DECL_OVERRIDE; + protected: void updateLayoutItems() Q_DECL_OVERRIDE; QQuickItem *itemAt(int index) const Q_DECL_OVERRIDE; @@ -84,15 +88,10 @@ protected: void rearrange(const QSizeF &size) Q_DECL_OVERRIDE; virtual void insertLayoutItems() {} - void itemChange(ItemChange change, const ItemChangeData &data) Q_DECL_OVERRIDE; signals: Q_REVISION(1) void layoutDirectionChanged(); -protected slots: - void onItemVisibleChanged(); - void onItemDestroyed(); - private: void removeGridItem(QGridLayoutItem *gridItem); Q_DECLARE_PRIVATE(QQuickGridLayoutBase) -- cgit v1.2.3