Remove WA_PaintOutsidePaintEvent
authorDebao Zhang <dbzhang800@gmail.com>
Sat, 24 Mar 2012 01:19:27 +0000 (18:19 -0700)
committerQt by Nokia <qt-info@nokia.com>
Wed, 28 Mar 2012 09:22:11 +0000 (11:22 +0200)
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 <Friedemann.Kleint@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
src/corelib/global/qnamespace.h
src/corelib/global/qnamespace.qdoc
src/gui/painting/qpainter.cpp
src/widgets/kernel/qwidget.cpp
src/widgets/kernel/qwidgetbackingstore.cpp
tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp

index cef244f..edf8a16 100644 (file)
@@ -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,
index 771f974..881b550 100644 (file)
     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
index eafbe87..2752fbd 100644 (file)
@@ -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<const QWidget *>(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<QPixmap *>(pd);
index e6d5a7a..8e6e436 100644 (file)
@@ -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()) {
index 2e9f072..93c6413 100644 (file)
@@ -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");
 }
 
index c6b2b49..3c98f89 100644 (file)
@@ -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);
 }
index 975c88d..0c769d5 100644 (file)
@@ -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