summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qdeclarativetext.cpp
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-07-21 04:16:34 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-07-21 04:16:34 (GMT)
commit3aeafb4839f49f524f10eae65be27fd189d37060 (patch)
tree5d35f55d8e68d8a2f5c2ab79d8614eed6a0ff28a /src/declarative/graphicsitems/qdeclarativetext.cpp
parent21806ff0921641b4e4d9d39721ab4ebeae74dddc (diff)
downloadQt-3aeafb4839f49f524f10eae65be27fd189d37060.zip
Qt-3aeafb4839f49f524f10eae65be27fd189d37060.tar.gz
Qt-3aeafb4839f49f524f10eae65be27fd189d37060.tar.bz2
Bounding rect of text was not always calculated correctly.
The boundingRect depended upon the image cache which may not become valid until after boundingRect is called. Task-number: QTBUG-12291 Reviewed-by: Michael Brasser
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativetext.cpp')
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp80
1 files changed, 27 insertions, 53 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp
index a1703c1..ab2be9c 100644
--- a/src/declarative/graphicsitems/qdeclarativetext.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetext.cpp
@@ -712,63 +712,37 @@ QRectF QDeclarativeText::boundingRect() const
int x = 0;
int y = 0;
- // Could include font max left/right bearings to either side of rectangle.
-
- if (d->cache || d->style != Normal) {
- QDeclarativeTextPrivate *dd = const_cast<QDeclarativeTextPrivate *>(d);
- dd->checkImgCache();
- switch (d->hAlign) {
- case AlignLeft:
- x = 0;
- break;
- case AlignRight:
- x = w - d->imgCache.width();
- break;
- case AlignHCenter:
- x = (w - d->imgCache.width()) / 2;
- break;
- }
-
- switch (d->vAlign) {
- case AlignTop:
- y = 0;
- break;
- case AlignBottom:
- y = h - d->imgCache.height();
- break;
- case AlignVCenter:
- y = (h - d->imgCache.height()) / 2;
- break;
- }
+ QSize size = d->cachedLayoutSize;
+ if (d->style != Normal)
+ size += QSize(2,2);
- return QRectF(x,y,d->imgCache.width(),d->imgCache.height());
- } else {
- switch (d->hAlign) {
- case AlignLeft:
- x = 0;
- break;
- case AlignRight:
- x = w - d->cachedLayoutSize.width();
- break;
- case AlignHCenter:
- x = (w - d->cachedLayoutSize.width()) / 2;
- break;
- }
+ // Could include font max left/right bearings to either side of rectangle.
- switch (d->vAlign) {
- case AlignTop:
- y = 0;
- break;
- case AlignBottom:
- y = h - d->cachedLayoutSize.height();
- break;
- case AlignVCenter:
- y = (h - d->cachedLayoutSize.height()) / 2;
- break;
- }
+ switch (d->hAlign) {
+ case AlignLeft:
+ x = 0;
+ break;
+ case AlignRight:
+ x = w - size.width();
+ break;
+ case AlignHCenter:
+ x = (w - size.width()) / 2;
+ break;
+ }
- return QRectF(x,y,d->cachedLayoutSize.width(),d->cachedLayoutSize.height());
+ switch (d->vAlign) {
+ case AlignTop:
+ y = 0;
+ break;
+ case AlignBottom:
+ y = h - size.height();
+ break;
+ case AlignVCenter:
+ y = (h - size.height()) / 2;
+ break;
}
+
+ return QRectF(x,y,size.width(),size.height());
}
void QDeclarativeText::geometryChanged(const QRectF &newGeometry,