diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp
index 8a5a6d4..f6ec5f3 100644
--- a/src/gui/painting/qbackingstore.cpp
+++ b/src/gui/painting/qbackingstore.cpp
@@ -91,6 +91,9 @@ public:
 */
 void QBackingStore::flush(const QRegion &region, QWindow *win, const QPoint &offset)
 {
+    qDebug() << win << region;
+    if (region.boundingRect().x() < 0)
+        qWarning("NEG!!");
     if (!win)
         win = window();
     if (!win->handle()) {
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 229cfc0..1c57d9a 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -2078,7 +2078,9 @@ void QWidgetPrivate::setSystemClip(QPaintDevice *paintDevice, const QRegion &reg
 void QWidgetPrivate::invalidateGraphicsEffectsRecursively()
 {
     Q_Q(QWidget);
+
     QWidget *w = q;
+    qDebug() << '>' << __FUNCTION__ << q << dirty;
     do {
         if (w->graphicsEffect()) {
             QWidgetEffectSourcePrivate *sourced =
@@ -2088,6 +2090,7 @@ void QWidgetPrivate::invalidateGraphicsEffectsRecursively()
         }
         w = w->parentWidget();
     } while (w);
+    qDebug() << '<' << __FUNCTION__  << q << dirty;
 }
 #endif //QT_NO_GRAPHICSEFFECT
 
diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp
index b86c376..f0c7120 100644
--- a/src/widgets/kernel/qwidgetbackingstore.cpp
+++ b/src/widgets/kernel/qwidgetbackingstore.cpp
@@ -304,6 +304,8 @@ void QWidgetBackingStore::beginPaint(QRegion &toClean, QWidget *widget, QBacking
 
     // Always flush repainted areas.
     dirtyOnScreen += toClean;
+    if (dirtyOnScreen.boundingRect().x() < 0)
+        qDebug("NEG1");
 
 #ifdef QT_NO_PAINT_DEBUG
     backingStore->beginPaint(toClean);
@@ -491,6 +493,7 @@ void QWidgetBackingStore::markDirty(const QRegion &rgn, QWidget *widget,
     if (widget->d_func()->paintOnScreen()) {
         if (widget->d_func()->dirty.isEmpty()) {
             widget->d_func()->dirty = rgn;
+            qDebug() << __FUNCTION__ << rgn;
             sendUpdateRequest(widget, updateTime);
             return;
         } else if (qt_region_strictContains(widget->d_func()->dirty, widget->rect())) {
@@ -501,6 +504,7 @@ void QWidgetBackingStore::markDirty(const QRegion &rgn, QWidget *widget,
 
         const bool eventAlreadyPosted = !widget->d_func()->dirty.isEmpty();
         widget->d_func()->dirty += rgn;
+        qDebug() << __FUNCTION__ << widget << widget->d_func()->dirty;
         if (!eventAlreadyPosted || updateTime == UpdateNow)
             sendUpdateRequest(widget, updateTime);
         return;
@@ -533,11 +537,16 @@ void QWidgetBackingStore::markDirty(const QRegion &rgn, QWidget *widget,
     if (bufferState == BufferInvalid) {
         const bool eventAlreadyPosted = !dirty.isEmpty() || updateRequestSent;
 #ifndef QT_NO_GRAPHICSEFFECT
-        if (widget->d_func()->graphicsEffect)
+        if (widget->d_func()->graphicsEffect) {
+            qDebug() << __FUNCTION__ << dirty.boundingRect();
             dirty += widget->d_func()->effectiveRectFor(rgn.boundingRect()).translated(offset);
+            qDebug() << __FUNCTION__ << "AFTER" << dirty.boundingRect() << "offset=" <<offset;
+        }
         else
 #endif //QT_NO_GRAPHICSEFFECT
             dirty += rgn.translated(offset);
+        qDebug() << __FUNCTION__ << "A2" << dirty << "offset=" <<offset;
+
         if (!eventAlreadyPosted || updateTime == UpdateNow)
             sendUpdateRequest(tlw, updateTime);
         return;
@@ -552,8 +561,12 @@ void QWidgetBackingStore::markDirty(const QRegion &rgn, QWidget *widget,
     if (widget->d_func()->inDirtyList) {
         if (!qt_region_strictContains(widget->d_func()->dirty, widgetRect)) {
 #ifndef QT_NO_GRAPHICSEFFECT
-            if (widget->d_func()->graphicsEffect)
+            if (widget->d_func()->graphicsEffect) {
+                qDebug() << __FUNCTION__ << dirty.boundingRect();
                 widget->d_func()->dirty += widget->d_func()->effectiveRectFor(rgn.boundingRect());
+                qDebug() << __FUNCTION__ << "AFTER2" << dirty.boundingRect() << "offset=" <<offset;
+            }
+
             else
 #endif //QT_NO_GRAPHICSEFFECT
                 widget->d_func()->dirty += rgn;
@@ -576,6 +589,8 @@ void QWidgetBackingStore::markDirty(const QRegion &rgn, QWidget *widget,
 void QWidgetBackingStore::markDirty(const QRect &rect, QWidget *widget,
                                     UpdateTime updateTime, BufferState bufferState)
 {
+    qDebug() << __FUNCTION__ << rect << widget;
+
     Q_ASSERT(tlw->d_func()->extra);
     Q_ASSERT(tlw->d_func()->extra->topextra);
     Q_ASSERT(!tlw->d_func()->extra->topextra->inTopLevelResize);
@@ -621,7 +636,10 @@ void QWidgetBackingStore::markDirty(const QRect &rect, QWidget *widget,
 
 
     const QRect widgetRect = widget->d_func()->effectiveRectFor(rect);
-    const QRect translatedRect(widgetRect.translated(widget->mapTo(tlw, QPoint())));
+    QRect translatedRect = widgetRect;
+    if (widget != tlw)
+        translatedRect.translate(widget->mapTo(tlw, QPoint()));
+//    translatedRect = translatedRect.intersect(QRect(QPoint(), tlw->size()));
     if (qt_region_strictContains(dirty, translatedRect)) {
         if (updateTime == UpdateNow)
             sendUpdateRequest(tlw, updateTime);
@@ -631,6 +649,7 @@ void QWidgetBackingStore::markDirty(const QRect &rect, QWidget *widget,
     if (bufferState == BufferInvalid) {
         const bool eventAlreadyPosted = !dirty.isEmpty();
         dirty += translatedRect;
+        qDebug() << __FUNCTION__<< dirty;
         if (!eventAlreadyPosted || updateTime == UpdateNow)
             sendUpdateRequest(tlw, updateTime);
         return;
@@ -645,6 +664,7 @@ void QWidgetBackingStore::markDirty(const QRect &rect, QWidget *widget,
     if (widget->d_func()->inDirtyList) {
         if (!qt_region_strictContains(widget->d_func()->dirty, widgetRect))
             widget->d_func()->dirty += widgetRect;
+        qDebug() << __FUNCTION__ << '2' << widget << widget->d_func()->dirty;
     } else {
         addDirtyWidget(widget, rect);
     }
@@ -672,8 +692,12 @@ void QWidgetBackingStore::markDirtyOnScreen(const QRegion &region, QWidget *widg
 
     // Top-level.
     if (widget == tlw) {
-        if (!widget->testAttribute(Qt::WA_WState_InPaintEvent))
+        if (!widget->testAttribute(Qt::WA_WState_InPaintEvent)) {
             dirtyOnScreen += region;
+            if (dirtyOnScreen.boundingRect().x() < 0)
+                qDebug("NEG2");
+        }
+
         return;
     }
 
@@ -681,8 +705,12 @@ void QWidgetBackingStore::markDirtyOnScreen(const QRegion &region, QWidget *widg
     if (!widget->internalWinId() && !widget->isWindow()) {
         QWidget *nativeParent = widget->nativeParentWidget();        // Alien widgets with the top-level as the native parent (common case).
         if (nativeParent == tlw) {
-            if (!widget->testAttribute(Qt::WA_WState_InPaintEvent))
+            if (!widget->testAttribute(Qt::WA_WState_InPaintEvent)) {
                 dirtyOnScreen += region.translated(topLevelOffset);
+                if (dirtyOnScreen.boundingRect().x() < 0)
+                    qDebug("NEG3");
+
+            }
             return;
         }
 
@@ -1118,6 +1146,8 @@ void QWidgetBackingStore::doSync()
     const bool updatesDisabled = !tlw->updatesEnabled();
     bool repaintAllWidgets = false;
 
+    qDebug() << __FUNCTION__ << ">" << dirty << "tlw=" << tlw;
+
     const bool inTopLevelResize = tlw->d_func()->maybeTopData()->inTopLevelResize;
     const QRect tlwRect(topLevelRect());
     const QRect surfaceGeometry(tlwRect.topLeft(), store->size());
@@ -1148,6 +1178,7 @@ void QWidgetBackingStore::doSync()
 
     // Contains everything that needs repaint.
     QRegion toClean(dirty);
+    qDebug() << __FUNCTION__ << "toClean(dirty)" << dirty;
 
     // Loop through all update() widgets and remove them from the list before they are
     // painted (in case someone calls update() in paintEvent). If the widget is opaque
@@ -1180,6 +1211,10 @@ void QWidgetBackingStore::doSync()
 
         const QRegion widgetDirty(w != tlw ? wd->dirty.translated(w->mapTo(tlw, QPoint()))
                                            : wd->dirty);
+        qDebug() << __FUNCTION__ << "Loop=" << w
+                 << w->size()
+                 << "widgetDirty=" << widgetDirty;
+
         toClean += widgetDirty;
 
 #ifndef QT_NO_GRAPHICSVIEW
@@ -1198,6 +1233,8 @@ void QWidgetBackingStore::doSync()
     }
     dirtyWidgets.clear();
 
+    qDebug() << __FUNCTION__ << "2 dirty=" << dirty << "toClean=" << toClean;
+
 #ifndef QT_NO_OPENGL
     // Find all render-to-texture child widgets (including self).
     // The search is cut at native widget boundaries, meaning that each native child widget
@@ -1263,6 +1300,9 @@ void QWidgetBackingStore::doSync()
     dirtyRenderToTextureWidgets.clear();
 #endif
 
+    qDebug() << __FUNCTION__ << "3 dirty=" << dirty << "toClean=" << toClean;
+
+
 #ifndef QT_NO_GRAPHICSVIEW
     if (tlw->d_func()->extra->proxyWidget) {
         updateStaticContentsSize();
@@ -1292,6 +1332,9 @@ void QWidgetBackingStore::doSync()
     dirty = QRegion();
     updateRequestSent = false;
 
+    qDebug() << __FUNCTION__ << "3 dirty=" << dirty << "toClean=" << toClean;
+
+
     // Paint opaque non overlapped widgets.
     for (int i = 0; i < opaqueNonOverlappedWidgets.size(); ++i) {
         QWidget *w = opaqueNonOverlappedWidgets[i];
@@ -1313,6 +1356,8 @@ void QWidgetBackingStore::doSync()
         wd->drawWidget(store->paintDevice(), toBePainted, offset, flags, 0, this);
     }
 
+    qDebug() << __FUNCTION__ << "4 dirtyCopy=" << dirtyCopy << "toClean=" << toClean;
+
     // Paint the rest with composition.
     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
         const int flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
