diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index acd80afddb..174b7eb5d5 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -549,12 +549,6 @@ void QWidgetPrivate::show_sys() window->resize(geomRect.size()); } - if (QBackingStore *store = q->backingStore()) { - if (store->size() != geomRect.size()) { - store->resize(geomRect.size()); - } - } - #ifndef QT_NO_CURSOR qt_qpa_set_cursor(q, false); // Needed in case cursor was set before show #endif @@ -762,11 +756,6 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) QPoint posInNativeParent = q->mapTo(q->nativeParentWidget(),QPoint()); q->windowHandle()->setGeometry(QRect(posInNativeParent,r.size())); } - const QWidgetBackingStore *bs = maybeBackingStore(); - if (bs && bs->store) { - if (isResize) - bs->store->resize(r.size()); - } if (needsShow) show_sys(); diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index fe877758ef..221e6825ed 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -940,7 +940,7 @@ void QWidgetBackingStore::sync(QWidget *exposedWidget, const QRegion &exposedReg } // Nothing to repaint. - if (!isDirty()) { + if (!isDirty() && store->size().isValid()) { qt_flush(exposedWidget, exposedRegion, store, tlw, tlwOffset, widgetTextures); return; } @@ -1035,7 +1035,7 @@ void QWidgetBackingStore::doSync() const QRect tlwRect(topLevelRect()); const QRect surfaceGeometry(tlwRect.topLeft(), store->size()); if ((fullUpdatePending || inTopLevelResize || surfaceGeometry.size() != tlwRect.size()) && !updatesDisabled) { - if (hasStaticContents()) { + if (hasStaticContents() && !store->size().isEmpty() ) { // Repaint existing dirty area and newly visible area. const QRect clipRect(0, 0, surfaceGeometry.width(), surfaceGeometry.height()); const QRegion staticRegion(staticContents(0, clipRect)); diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 21e0286086..dd3d041f56 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -441,6 +441,8 @@ private slots: void mouseDoubleClickBubbling_QTBUG29680(); void largerThanScreen_QTBUG30142(); + void resizeStaticContentsChildWidget_QTBUG35282(); + private: bool ensureScreenSize(int width, int height); QWidget *testWidget; @@ -10220,5 +10222,26 @@ void tst_QWidget::largerThanScreen_QTBUG30142() QVERIFY(widget2.frameGeometry().x() >= 0); } +void tst_QWidget::resizeStaticContentsChildWidget_QTBUG35282() +{ + QWidget widget; + widget.resize(200,200); + + UpdateWidget childWidget(&widget); + childWidget.setAttribute(Qt::WA_StaticContents); + childWidget.setAttribute(Qt::WA_OpaquePaintEvent); + childWidget.setGeometry(250, 250, 500, 500); + + widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); + QVERIFY(childWidget.numPaintEvents == 0); + childWidget.reset(); + + widget.resize(1000,1000); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); + QGuiApplication::sync(); + QVERIFY(childWidget.numPaintEvents >= 1); +} + QTEST_MAIN(tst_QWidget) #include "tst_qwidget.moc"