From: Debao Zhang Date: Sat, 24 Mar 2012 01:19:27 +0000 (-0700) Subject: Remove WA_PaintOutsidePaintEvent X-Git-Tag: 071012110112~1235^2^2~174 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d2b1c2ef1f1fea3200d8dee5c58fe79649fd13bb;p=profile%2Fivi%2Fqtbase.git Remove WA_PaintOutsidePaintEvent WA_PaintOutsidePaintEvent is only suggested to be used when porting Qt3 code to Qt 4 under X11 platform. and it has been broken now. Change-Id: Ie4297b2a449f1055ca10ada9efb930e6018b1efb Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index cef244f..edf8a16 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -342,7 +342,6 @@ public: WA_UpdatesDisabled = 10, WA_Mapped = 11, WA_MacNoClickThrough = 12, // Mac only - WA_PaintOutsidePaintEvent = 13, WA_InputMethodEnabled = 14, WA_WState_Visible = 15, WA_WState_Hidden = 16, diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 771f974..881b550 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -993,11 +993,6 @@ require native painting primitives, you need to reimplement QWidget::paintEngine() to return 0 and set this flag. - \value WA_PaintOutsidePaintEvent Makes it possible to use QPainter to - paint on the widget outside \l{QWidget::paintEvent()}{paintEvent()}. This - flag is not supported on Windows, Mac OS X or Embedded Linux. We recommend - that you use it only when porting Qt 3 code to Qt 4. - \value WA_PaintUnclipped Makes all painters operating on this widget unclipped. Children of this widget or other widgets in front of it do not clip the area the painter can paint on. This flag is only supported for diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index eafbe87..2752fbd 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -970,10 +970,7 @@ void QPainterPrivate::updateState(QPainterState *newState) \warning When the paintdevice is a widget, QPainter can only be used inside a paintEvent() function or in a function called by - paintEvent(); that is unless the Qt::WA_PaintOutsidePaintEvent - widget attribute is set. On Mac OS X and Windows, you can only - paint in a paintEvent() function regardless of this attribute's - setting. + paintEvent(). \tableofcontents @@ -1760,25 +1757,6 @@ bool QPainter::begin(QPaintDevice *pd) d->engine->state = d->state; switch (pd->devType()) { -#if 0 - // is this needed any more?? - case QInternal::Widget: - { - const QWidget *widget = static_cast(pd); - Q_ASSERT(widget); - - const bool paintOutsidePaintEvent = widget->testAttribute(Qt::WA_PaintOutsidePaintEvent); - const bool inPaintEvent = widget->testAttribute(Qt::WA_WState_InPaintEvent); - - // Adjust offset for alien widgets painting outside the paint event. - if (!inPaintEvent && paintOutsidePaintEvent && !widget->internalWinId() - && widget->testAttribute(Qt::WA_WState_Created)) { - const QPoint offset = widget->mapTo(widget->nativeParentWidget(), QPoint()); - d->state->redirectionMatrix.translate(offset.x(), offset.y()); - } - break; - } -#endif case QInternal::Pixmap: { QPixmap *pm = static_cast(pd); diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index e6d5a7a..8e6e436 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -5128,7 +5128,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP paintEngine->d_func()->systemClip = QRegion(); } q->setAttribute(Qt::WA_WState_InPaintEvent, false); - if (q->paintingActive() && !q->testAttribute(Qt::WA_PaintOutsidePaintEvent)) + if (q->paintingActive()) qWarning("QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent"); if (paintEngine && paintEngine->autoDestruct()) { diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index 2e9f072..93c6413 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -1364,7 +1364,7 @@ void QWidgetPrivate::repaint_sys(const QRegion &rgn) QWidgetBackingStore::unflushPaint(q, toBePainted); #endif - if (!q->testAttribute(Qt::WA_PaintOutsidePaintEvent) && q->paintingActive()) + if (q->paintingActive()) qWarning("QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent"); } diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp index c6b2b49..3c98f89 100644 --- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp @@ -1384,7 +1384,6 @@ void tst_QGraphicsWidget::setAttribute_data() QTest::newRow("WA_RightToLeft") << Qt::WA_RightToLeft << true; QTest::newRow("WA_SetStyle") << Qt::WA_SetStyle << true; QTest::newRow("WA_Resized") << Qt::WA_Resized << true; - QTest::newRow("unsupported") << Qt::WA_PaintOutsidePaintEvent << false; } // void setAttribute(Qt::WidgetAttribute attribute, bool on = true) public @@ -1393,8 +1392,6 @@ void tst_QGraphicsWidget::setAttribute() QFETCH(Qt::WidgetAttribute, attribute); QFETCH(bool, supported); SubQGraphicsWidget widget; - if (attribute == Qt::WA_PaintOutsidePaintEvent) - QTest::ignoreMessage(QtWarningMsg, "QGraphicsWidget::setAttribute: unsupported attribute 13"); widget.setAttribute(attribute); QCOMPARE(widget.testAttribute(attribute), supported); } diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 975c88d..0c769d5 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -377,9 +377,6 @@ private slots: #endif void windowFlags(); void initialPosForDontShowOnScreenWidgets(); -#ifdef Q_WS_X11 - void paintOutsidePaintEvent(); -#endif void updateOnDestroyedSignal(); void toplevelLineEditFocus(); void inputFocus_task257832(); @@ -8711,42 +8708,6 @@ void tst_QWidget::initialPosForDontShowOnScreenWidgets() } } -#ifdef Q_WS_X11 -void tst_QWidget::paintOutsidePaintEvent() -{ - QWidget widget; - widget.resize(200, 200); - - QWidget child1(&widget); - child1.resize(100, 100); - child1.setPalette(Qt::red); - child1.setAutoFillBackground(true); - - QWidget child2(&widget); - child2.setGeometry(50, 50, 100, 100); - child2.setPalette(Qt::blue); - child2.setAutoFillBackground(true); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - QTest::qWait(60); - - const QPixmap before = QPixmap::grabWindow(widget.winId()); - - // Child 1 should be clipped by child 2, so nothing should change. - child1.setAttribute(Qt::WA_PaintOutsidePaintEvent); - QPainter painter(&child1); - painter.fillRect(child1.rect(), Qt::red); - painter.end(); - XSync(QX11Info::display(), false); // Flush output buffer. - QTest::qWait(60); - - const QPixmap after = QPixmap::grabWindow(widget.winId()); - - QCOMPARE(before, after); -} -#endif - class MyEvilObject : public QObject { Q_OBJECT