summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicswidget.cpp
diff options
context:
space:
mode:
authorJohn Tapsell <john.tapsell.ext@basyskom.de>2011-05-27 06:31:55 (GMT)
committerJan-Arve Sæther <jan-arve.saether@nokia.com>2011-05-27 11:02:31 (GMT)
commit575e832fd053df98e60aefebbc5843a4864f2523 (patch)
tree218fea560ec7064698536aa60aeec7188f540803 /src/gui/graphicsview/qgraphicswidget.cpp
parent6c10e72fc838f8f9f5c3a3e4a297088b1725262c (diff)
downloadQt-575e832fd053df98e60aefebbc5843a4864f2523.zip
Qt-575e832fd053df98e60aefebbc5843a4864f2523.tar.gz
Qt-575e832fd053df98e60aefebbc5843a4864f2523.tar.bz2
Fixed move a QGraphicsWidget and invalidate its layout at the same time
QGraphicsWidget::setGeometry() could sometimes call QGraphicsLayoutItem::setGeometry() with an uninitialized rectangle. This happened in the specific case where the widget had a layout that was not active, and where setPos was called on the widget. This would in turn cause it to enter setGeometry() where it would act as expected. However, due to the fact that we sent a LayoutRequest event at the end of that function, it could result in that QGraphicsLayout::activate() would call setGeometry again. Now, we would actually enter setGeometry, where wd->inSetPos == 1. Then, we would not enter the "if (!wd->inSetPos)" block nor the "if (moved)" block. It would then end up calling QGraphicsLayoutItem::setGeometry(newGeom), where newGeom was uninitialized. Bug happens only when QGraphicsLayout::setInstantInvalidatePropagation(true) was used, because that was the condition for sending the layout request from setGeometry() Tracked down and written by Stanislav Ionascu. Reviewed-by: Jan-Arve Sæther
Diffstat (limited to 'src/gui/graphicsview/qgraphicswidget.cpp')
-rw-r--r--src/gui/graphicsview/qgraphicswidget.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp
index 804394a..7048fcc 100644
--- a/src/gui/graphicsview/qgraphicswidget.cpp
+++ b/src/gui/graphicsview/qgraphicswidget.cpp
@@ -347,11 +347,10 @@ void QGraphicsWidget::setGeometry(const QRectF &rect)
{
QGraphicsWidgetPrivate *wd = QGraphicsWidget::d_func();
QGraphicsLayoutItemPrivate *d = QGraphicsLayoutItem::d_ptr.data();
- QRectF newGeom;
+ QRectF newGeom = rect;
QPointF oldPos = d->geom.topLeft();
if (!wd->inSetPos) {
setAttribute(Qt::WA_Resized);
- newGeom = rect;
newGeom.setSize(rect.size().expandedTo(effectiveSizeHint(Qt::MinimumSize))
.boundedTo(effectiveSizeHint(Qt::MaximumSize)));