From 0088f760439b4f6f98342d3e22ecadbb13aaf06a Mon Sep 17 00:00:00 2001 From: Vitaly Fanaskov Date: Fri, 30 Nov 2018 16:10:37 +0100 Subject: Fix inability to edit lines in QGraphicsTextItem when pageSize is set Previous implementation relies on the fact that the only text document with height -1 can grow or shrink vertically, and, hence, a bounding rect should be updated under this circumstances. But method QTextDocument::setPageSize might set a height different from -1, and QGraphicsTextItem will be growing/shrinking vertically as well. So, we have to relax condition to cover all use cases. Bounding rect will be updated if new size is different from current size. This also doesn't affect performance. Fixes: QTBUG-55527 Change-Id: Id2c8e15d859aff9dde62c8ee14a6859c0c03f0d4 Reviewed-by: Lars Knoll --- src/widgets/graphicsview/qgraphicsitem.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/widgets/graphicsview') diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index e81eab4c46..3a9bfab298 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -10569,14 +10569,11 @@ void QGraphicsTextItemPrivate::_q_update(QRectF rect) */ void QGraphicsTextItemPrivate::_q_updateBoundingRect(const QSizeF &size) { - if (!control) return; // can't happen - const QSizeF pageSize = control->document()->pageSize(); - // paged items have a constant (page) size - if (size == boundingRect.size() || pageSize.height() != -1) - return; - qq->prepareGeometryChange(); - boundingRect.setSize(size); - qq->update(); + if (size != boundingRect.size()) { + qq->prepareGeometryChange(); + boundingRect.setSize(size); + qq->update(); + } } /*! -- cgit v1.2.3