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 d6f971c854.

Change-Id: If44e2a7e7fb134c228674cf228bbee0d5520e04f
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
This commit is contained in:
Friedemann Kleint 2012-05-25 14:55:44 +02:00 committed by Qt by Nokia
parent 97659d87be
commit 65a264c4a1

View File

@ -4776,17 +4776,15 @@ static void sendResizeEvents(QWidget *target)
/* INVOKABLE since used by QPixmap::grabWidget(). */ /* INVOKABLE since used by QPixmap::grabWidget(). */
QPixmap QWidget::grab(const QRect &rectangle) QPixmap QWidget::grab(const QRect &rectangle)
{ {
Q_D(const QWidget); Q_D(QWidget);
if (testAttribute(Qt::WA_PendingResizeEvent) || !testAttribute(Qt::WA_WState_Created)) if (testAttribute(Qt::WA_PendingResizeEvent) || !testAttribute(Qt::WA_WState_Created))
sendResizeEvents(this); sendResizeEvents(this);
adjustSize(); const QWidget::RenderFlags renderFlags = QWidget::DrawWindowBackground | QWidget::DrawChildren | QWidget::IgnoreMask;
QRect r(rectangle); QRect r(rectangle);
if (r.width() < 0) if (r.width() < 0 || r.height() < 0)
r.setWidth(width() - rectangle.x()); r = d->prepareToRender(QRegion(), renderFlags).boundingRect();
if (r.height() < 0)
r.setHeight(height() - rectangle.y());
if (!r.intersects(rect())) if (!r.intersects(rect()))
return QPixmap(); return QPixmap();
@ -4794,8 +4792,7 @@ QPixmap QWidget::grab(const QRect &rectangle)
QPixmap res(r.size()); QPixmap res(r.size());
if (!d->isOpaque) if (!d->isOpaque)
res.fill(Qt::transparent); res.fill(Qt::transparent);
render(&res, QPoint(), QRegion(r), QWidget::DrawWindowBackground render(&res, QPoint(), QRegion(r), renderFlags);
| QWidget::DrawChildren | QWidget::IgnoreMask);
return res; return res;
} }