diff --git a/examples/widgets/mainwindows/dockwidgets/dockwidgets.pro b/examples/widgets/mainwindows/dockwidgets/dockwidgets.pro
index 3acded5ed3..bd825d5558 100644
--- a/examples/widgets/mainwindows/dockwidgets/dockwidgets.pro
+++ b/examples/widgets/mainwindows/dockwidgets/dockwidgets.pro
@@ -1,7 +1,7 @@
 QT += widgets
 requires(qtConfig(listwidget))
 qtHaveModule(printsupport): QT += printsupport
-
+CONFIG+=console
 HEADERS         = mainwindow.h
 SOURCES         = main.cpp \
                   mainwindow.cpp
diff --git a/examples/widgets/mainwindows/dockwidgets/main.cpp b/examples/widgets/mainwindows/dockwidgets/main.cpp
index ff3ba506a8..4908494c25 100644
--- a/examples/widgets/mainwindows/dockwidgets/main.cpp
+++ b/examples/widgets/mainwindows/dockwidgets/main.cpp
@@ -49,12 +49,15 @@
 ****************************************************************************/
 
 #include <QApplication>
+#include <QDebug>
 
 #include "mainwindow.h"
 
 int main(int argc, char *argv[])
 {
+
     QApplication app(argc, argv);
+    qDebug() << "Qt" << qVersion() << app.platformName();
     Q_INIT_RESOURCE(dockwidgets);
     MainWindow mainWin;
     mainWin.show();
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 5ac1ac698e..b33a0839ee 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -12359,6 +12359,7 @@ static void releaseMouseGrabOfWidget(QWidget *widget)
 */
 void QWidget::grabMouse()
 {
+    qDebug() << __FUNCTION__ << this;
     grabMouseForWidget(this);
 }
 
@@ -12381,6 +12382,7 @@ void QWidget::grabMouse()
 #ifndef QT_NO_CURSOR
 void QWidget::grabMouse(const QCursor &cursor)
 {
+    qDebug() << __FUNCTION__ << this;
     grabMouseForWidget(this, &cursor);
 }
 #endif
@@ -12403,6 +12405,7 @@ bool QWidgetPrivate::stealMouseGrab(bool grab)
 */
 void QWidget::releaseMouse()
 {
+    qDebug() << __FUNCTION__ << this;
     releaseMouseGrabOfWidget(this);
 }
 
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index 05ec3aface..e6d7f8fe3d 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -837,6 +837,7 @@ void QDockWidgetPrivate::startDrag(bool group)
  */
 void QDockWidgetPrivate::endDrag(bool abort)
 {
+    qDebug() << __FUNCTION__ << "ab=" << abort << "drag=" << (state && state->dragging);
     Q_Q(QDockWidget);
     Q_ASSERT(state != 0);
 
@@ -908,6 +909,7 @@ bool QDockWidgetPrivate::isAnimating() const
 
 bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event)
 {
+    qDebug() << __FUNCTION__ << event;
 #if QT_CONFIG(mainwindow)
     Q_Q(QDockWidget);
 
@@ -944,6 +946,7 @@ bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event)
 
 bool QDockWidgetPrivate::mouseDoubleClickEvent(QMouseEvent *event)
 {
+    qDebug() << __FUNCTION__ << event;
     QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
 
     if (!dwLayout->nativeWindowDeco()) {
@@ -960,6 +963,7 @@ bool QDockWidgetPrivate::mouseDoubleClickEvent(QMouseEvent *event)
 
 bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event)
 {
+    qDebug() << __FUNCTION__ << event;
     bool ret = false;
 #if QT_CONFIG(mainwindow)
     Q_Q(QDockWidget);
@@ -1005,6 +1009,7 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event)
 bool QDockWidgetPrivate::mouseReleaseEvent(QMouseEvent *event)
 {
 #if QT_CONFIG(mainwindow)
+    qDebug() << __FUNCTION__ << event;
 
     if (event->button() == Qt::LeftButton && state && !state->nca) {
         endDrag();
@@ -1084,12 +1089,22 @@ void QDockWidgetPrivate::recalculatePressPos(QResizeEvent *event)
 void QDockWidgetPrivate::moveEvent(QMoveEvent *event)
 {
     Q_Q(QDockWidget);
+    if (!state ) {
+        qDebug() << __FUNCTION__ << "bail1: no state";
+        return;
+    }
+
+    qDebug() << __FUNCTION__ << event << "drag=" << state->dragging << "nca" << state->nca;
 
-    if (state == 0 || !state->dragging || !state->nca)
+    if (!state->dragging || !state->nca) {
+        qDebug() << __FUNCTION__ << "bail1";
         return;
+    }
 
-    if (!q->isWindow() && qobject_cast<QDockWidgetGroupWindow*>(parent) == 0)
+    if (!q->isWindow() && qobject_cast<QDockWidgetGroupWindow*>(parent) == 0) {
+        qDebug() << __FUNCTION__ << "bail3";
         return;
+    }
 
     // When the native window frame is being dragged, all we get is these mouse
     // move events.
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index 0fb3a86cf8..42c151b000 100644
--- a/src/widgets/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
@@ -2069,6 +2069,7 @@ void QMainWindowLayout::revert(QLayoutItem *widgetItem)
     QWidget *widget = widgetItem->widget();
     layoutState = savedState;
     currentGapPos = layoutState.indexOf(widget);
+    qDebug() << __FUNCTION__ << currentGapPos;
     if (currentGapPos.isEmpty())
         return;
     fixToolBarOrientation(widgetItem, currentGapPos.at(1));
@@ -2082,6 +2083,8 @@ void QMainWindowLayout::revert(QLayoutItem *widgetItem)
 bool QMainWindowLayout::plug(QLayoutItem *widgetItem)
 {
 #if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget) && QT_CONFIG(tabbar)
+    qDebug() << __FUNCTION__ << widgetItem << "currentHoveredFloat=" << currentHoveredFloat
+             << "currentGapPos=" << currentGapPos;
     if (currentHoveredFloat) {
         QWidget *widget = widgetItem->widget();
         QList<int> previousPath = layoutState.indexOf(widget);
@@ -2106,12 +2109,16 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem)
         globalRect.moveTopLeft(currentHoveredFloat->mapToGlobal(globalRect.topLeft()));
         pluggingWidget = widget;
         widgetAnimator.animate(widget, globalRect, dockOptions & QMainWindow::AnimatedDocks);
+        qDebug() << __FUNCTION__ << "1 ok";
         return true;
     }
 #endif
 
-    if (!parentWidget()->isVisible() || parentWidget()->isMinimized() || currentGapPos.isEmpty())
+    qDebug() << __FUNCTION__ <<  "currentGapPos.isEmpty=" << currentGapPos.isEmpty();
+    if (!parentWidget()->isVisible() || parentWidget()->isMinimized() || currentGapPos.isEmpty()) {
+        qDebug() << __FUNCTION__ << "bail out";
         return false;
+    }
 
     fixToolBarOrientation(widgetItem, currentGapPos.at(1));
 
@@ -2131,8 +2138,10 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem)
     QList<int> previousPath = layoutState.indexOf(widget);
 
     const QLayoutItem *it = layoutState.plug(currentGapPos);
-    if (!it)
+    if (!it) {
+        qDebug() << __FUNCTION__ << "bail out plug fail";
         return false;
+    }
     Q_ASSERT(it == widgetItem);
     if (!previousPath.isEmpty())
         layoutState.remove(previousPath);
@@ -2152,7 +2161,7 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem)
     }
 #endif
     widgetAnimator.animate(widget, globalRect, dockOptions & QMainWindow::AnimatedDocks);
-
+    qDebug() << __FUNCTION__ << "ret";
     return true;
 }
 
@@ -2237,6 +2246,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
 #endif
 
         savedState.clear();
+        qDebug() <<  __FUNCTION__ << "clear";
         currentGapPos.clear();
         pluggingWidget = 0;
 #if QT_CONFIG(dockwidget)
@@ -2282,6 +2292,7 @@ void QMainWindowLayout::restore(bool keepSavedState)
     applyState(layoutState);
     if (!keepSavedState)
         savedState.clear();
+    qDebug() <<  __FUNCTION__ << "clear";
     currentGapPos.clear();
     pluggingWidget = 0;
     updateGapIndicator();
@@ -2564,7 +2575,9 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
         || pluggingWidget != 0 || widgetItem == 0)
         return;
 
+
     QWidget *widget = widgetItem->widget();
+    qDebug() << __FUNCTION__ << widget << mousePos;
 
 #if QT_CONFIG(dockwidget)
     if ((dockOptions & QMainWindow::GroupedDragging) && (qobject_cast<QDockWidget*>(widget)
@@ -2666,6 +2679,7 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
         return; // the gap is already there
 
     currentGapPos = path;
+    qDebug() <<  __FUNCTION__ << "assigned" << currentGapPos;
     if (path.isEmpty()) {
         fixToolBarOrientation(widgetItem, 2); // 2 = top dock, ie. horizontal
         restore(true);
