From 7c48cf655580e118ee7faf21a9f346bd68292e26 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 27 Oct 2020 16:27:01 +0100 Subject: nativestyle: only draw the control if the control is visible Check if the control is visible before taking the time to draw the image. Change-Id: Icb64b85355e1341279a95e9035ae18d91c14d6a8 Reviewed-by: Mitch Curtis --- src/imports/nativestyle/items/qquickstyleitem.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/imports/nativestyle/items/qquickstyleitem.cpp') diff --git a/src/imports/nativestyle/items/qquickstyleitem.cpp b/src/imports/nativestyle/items/qquickstyleitem.cpp index bf3d9129..b5005a8b 100644 --- a/src/imports/nativestyle/items/qquickstyleitem.cpp +++ b/src/imports/nativestyle/items/qquickstyleitem.cpp @@ -220,6 +220,20 @@ void QQuickStyleItem::geometryChange(const QRectF &newGeometry, const QRectF &ol markGeometryDirty(); } +void QQuickStyleItem::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data) +{ + QQuickItem::itemChange(change, data); + + switch (change) { + case QQuickItem::ItemVisibleHasChanged: + if (data.boolValue) + markImageDirty(); + break; + default: + break; + } +} + void QQuickStyleItem::updateGeometry() { qqc2DebugHeading("GEOMETRY"); @@ -321,7 +335,7 @@ void QQuickStyleItem::updatePolish() QScopedValueRollback guard(m_polishing, true); const bool dirtyGeometry = m_dirty & DirtyFlag::Geometry; - const bool dirtyImage = (m_dirty & DirtyFlag::Image) || (!m_useNinePatchImage && dirtyGeometry); + const bool dirtyImage = isVisible() && ((m_dirty & DirtyFlag::Image) || (!m_useNinePatchImage && dirtyGeometry)); if (dirtyGeometry) updateGeometry(); -- cgit v1.2.3