Remove dirty flag validation during geometry change in the layout

The patch 9ad9d05f26 adds validation
to avoid rearrange in the layout as there is possibility to refer
invalid QGridLayoutItem (particularly during item removal from the
layout). The same can be fixed through m_disableRearrange flag which
cause rearrange to happen in next polish (as with the earlier fix)
instead of geometryChange().

Fixes: QTBUG-120592
Pick-to: 6.7 6.6 6.5
Change-Id: Ia17a41eeba46797631263d865de055b46e1208f1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
This commit is contained in:
Santhosh Kumar 2024-01-09 14:05:56 +01:00
parent 7ab9ba6062
commit d85de8da60
1 changed files with 8 additions and 2 deletions

View File

@ -787,6 +787,7 @@ QQuickLayoutAttached *QQuickLayout::qmlAttachedProperties(QObject *object)
void QQuickLayout::updatePolish()
{
qCDebug(lcQuickLayouts) << "updatePolish() ENTERING" << this;
d_func()->m_disableRearrange = false;
m_inUpdatePolish = true;
// Might have become "undirty" before we reach this updatePolish()
@ -915,8 +916,13 @@ void QQuickLayout::itemChange(ItemChange change, const ItemChangeData &value)
maybeSubscribeToBaseLineOffsetChanges(item);
QQuickItemPrivate::get(item)->removeItemChangeListener(this, changeTypes);
qCDebug(lcQuickLayouts) << "ChildRemoved" << item;
if (isReady())
if (isReady()) {
invalidate();
// The invalidate() triggers polish and this relayout items in the
// layout engine. But if there is any geometry change from the same
// item (due to deferred deletion), its better to skip rearrange
d_func()->m_disableRearrange = true;
}
}
QQuickItem::itemChange(change, value);
}
@ -925,7 +931,7 @@ void QQuickLayout::geometryChange(const QRectF &newGeometry, const QRectF &oldGe
{
Q_D(QQuickLayout);
QQuickItem::geometryChange(newGeometry, oldGeometry);
if (invalidated() || d->m_disableRearrange || !isReady())
if (d->m_disableRearrange || !isReady())
return;
qCDebug(lcQuickLayouts) << "QQuickLayout::geometryChange" << newGeometry << oldGeometry;