From: Friedemann Kleint Date: Fri, 25 May 2012 12:55:44 +0000 (+0200) Subject: QWidget::grab(): Do not call adjustSize() unconditionally. X-Git-Tag: 071012110112~751 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=65a264c4a16fc995ec2b495dd8839d9965ceb605;p=profile%2Fivi%2Fqtbase.git QWidget::grab(): Do not call adjustSize() unconditionally. This breaks the combo dropdown animation on Windows as it uses special layout tricks and potentially other (unlaid-out) widgets. If the size is unknown, call prepareToRender instead. Reverts d6f971c8547d7f0619b63f7e07f1c292e811b45f. Change-Id: If44e2a7e7fb134c228674cf228bbee0d5520e04f Reviewed-by: Samuel Rødal --- diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 467b1fc..3d0ffd9 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -4776,17 +4776,15 @@ static void sendResizeEvents(QWidget *target) /* INVOKABLE since used by QPixmap::grabWidget(). */ QPixmap QWidget::grab(const QRect &rectangle) { - Q_D(const QWidget); + Q_D(QWidget); if (testAttribute(Qt::WA_PendingResizeEvent) || !testAttribute(Qt::WA_WState_Created)) sendResizeEvents(this); - adjustSize(); + const QWidget::RenderFlags renderFlags = QWidget::DrawWindowBackground | QWidget::DrawChildren | QWidget::IgnoreMask; QRect r(rectangle); - if (r.width() < 0) - r.setWidth(width() - rectangle.x()); - if (r.height() < 0) - r.setHeight(height() - rectangle.y()); + if (r.width() < 0 || r.height() < 0) + r = d->prepareToRender(QRegion(), renderFlags).boundingRect(); if (!r.intersects(rect())) return QPixmap(); @@ -4794,8 +4792,7 @@ QPixmap QWidget::grab(const QRect &rectangle) QPixmap res(r.size()); if (!d->isOpaque) res.fill(Qt::transparent); - render(&res, QPoint(), QRegion(r), QWidget::DrawWindowBackground - | QWidget::DrawChildren | QWidget::IgnoreMask); + render(&res, QPoint(), QRegion(r), renderFlags); return res; }