diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
index 1d10de9..f84b360 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -48,6 +48,7 @@
 #include <private/qlayoutengine_p.h>
 
 #include <qpainter.h>
+#include <qdebug.h>
 #include <qstyleoption.h>
 
 #ifndef QT_NO_DOCKWIDGET
@@ -1142,6 +1143,7 @@ static QRect dockedGeometry(QWidget *widget)
 
 bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem)
 {
+    qDebug() << __FUNCTION__ << path ;
     Q_ASSERT(!path.isEmpty());
 
     bool insert_tabbed = false;
@@ -1168,6 +1170,7 @@ bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWid
             QLayoutItem *widgetItem = item.widgetItem;
             QPlaceHolderItem *placeHolderItem = item.placeHolderItem;
             QRect r = subinfo == 0 ? widgetItem ? dockedGeometry(widgetItem->widget()) : placeHolderItem->topLevelRect : subinfo->rect;
+            qDebug() << __FUNCTION__ << r;
 
             Qt::Orientation opposite = o == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal;
 #ifdef QT_NO_TABBAR
@@ -2407,6 +2410,7 @@ QList<int> QDockAreaLayout::indexOf(QWidget *dockWidget) const
 
 QList<int> QDockAreaLayout::gapIndex(const QPoint &pos) const
 {
+    qDebug() << __FUNCTION__ << pos;
     QMainWindow::DockOptions opts = mainWindow->dockOptions();
     bool nestingEnabled = opts & QMainWindow::AllowNestedDocks;
     QDockAreaLayoutInfo::TabMode tabMode = QDockAreaLayoutInfo::NoTabs;
@@ -2424,6 +2428,7 @@ QList<int> QDockAreaLayout::gapIndex(const QPoint &pos) const
 
     for (int i = 0; i < QInternal::DockCount; ++i) {
         const QDockAreaLayoutInfo &info = docks[i];
+        qDebug() << __FUNCTION__ << i << info.rect <<  info.rect.contains(pos);
 
         if (!info.isEmpty() && info.rect.contains(pos)) {
             QList<int> result
@@ -2574,6 +2579,7 @@ QRect QDockAreaLayout::separatorRect(const QList<int> &path) const
 
 bool QDockAreaLayout::insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem)
 {
+    qDebug() << __FUNCTION__ << path;
     Q_ASSERT(!path.isEmpty());
     const int index = path.first();
     Q_ASSERT(index >= 0 && index < QInternal::DockCount);
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index 20f35cb..7c75f3e 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -717,6 +717,7 @@ void QDockWidgetPrivate::_q_toggleTopLevel()
  */
 void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca)
 {
+    qDebug() << __FUNCTION__ << pos << nca;
     Q_Q(QDockWidget);
 
     if (state != 0)
@@ -744,6 +745,7 @@ void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca)
  */
 void QDockWidgetPrivate::startDrag(bool group)
 {
+    qDebug() << __FUNCTION__ << group;
     Q_Q(QDockWidget);
 
     if (state == 0 || state->dragging)
@@ -766,8 +768,10 @@ void QDockWidgetPrivate::startDrag(bool group)
         state->ownWidgetItem = true;
     }
 
-    if (state->ctrlDrag)
+    if (state->ctrlDrag) {
+        qDebug() << __FUNCTION__ << "Calling restore";
         layout->restore();
+    }
 
     state->dragging = true;
 }
@@ -779,6 +783,7 @@ void QDockWidgetPrivate::startDrag(bool group)
  */
 void QDockWidgetPrivate::endDrag(bool abort)
 {
+    qDebug() << __FUNCTION__;
     Q_Q(QDockWidget);
     Q_ASSERT(state != 0);
 
@@ -787,12 +792,14 @@ void QDockWidgetPrivate::endDrag(bool abort)
     if (state->dragging) {
         QMainWindowLayout *mwLayout = qt_mainwindow_layout_from_dock(q);
         Q_ASSERT(mwLayout != 0);
-
+        qDebug() << __FUNCTION__ << "abort=" << abort;
         if (abort || !mwLayout->plug(state->widgetItem)) {
+            qDebug() << __FUNCTION__ << "remain fl";
             if (hasFeature(this, QDockWidget::DockWidgetFloatable)) {
                 // This QDockWidget will now stay in the floating state.
                 if (state->ownWidgetItem)
                     delete state->widgetItem;
+                qDebug() << __FUNCTION__ << "calling restore";
                 mwLayout->restore();
                 QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
                 if (!dwLayout->nativeWindowDeco()) {
@@ -928,8 +935,10 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event)
         else
             q->move(pos);
 
-        if (state && !state->ctrlDrag)
+        if (state && !state->ctrlDrag) {
+            qDebug() << __FUNCTION__ << "calling hover" << event->globalPos();
             mwlayout->hover(state->widgetItem, event->globalPos());
+        }
 
         ret = true;
     }
@@ -1037,6 +1046,8 @@ void QDockWidgetPrivate::moveEvent(QMoveEvent *event)
     Q_ASSERT(layout != 0);
 
     QPoint globalMousePos = event->pos() + state->pressPos;
+    qDebug() << "event->pos()=" << event->pos() << "presspos=" << state->pressPos
+             << "->" << globalMousePos;
     layout->hover(state->widgetItem, globalMousePos);
 }
 
@@ -1045,6 +1056,7 @@ void QDockWidgetPrivate::unplug(const QRect &rect)
     Q_Q(QDockWidget);
     QRect r = rect;
     r.moveTopLeft(q->mapToGlobal(QPoint(0, 0)));
+    qDebug() << __FUNCTION__ << r;
     QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
     if (dwLayout->nativeWindowDeco(true))
         r.adjust(0, dwLayout->titleHeight(), 0, 0);
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index f581fe4..5083689 100644
--- a/src/widgets/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
@@ -634,6 +634,7 @@ QWidget *QMainWindowLayoutState::centralWidget() const
 QList<int> QMainWindowLayoutState::gapIndex(QWidget *widget,
                                             const QPoint &pos) const
 {
+    qDebug() << __FUNCTION__ << widget << pos;
     QList<int> result;
 
 #ifndef QT_NO_TOOLBAR
@@ -662,6 +663,7 @@ QList<int> QMainWindowLayoutState::gapIndex(QWidget *widget,
 
 bool QMainWindowLayoutState::insertGap(const QList<int> &path, QLayoutItem *item)
 {
+    qDebug() << __FUNCTION__ << path << item;
     if (path.isEmpty())
         return false;
 
@@ -670,12 +672,14 @@ bool QMainWindowLayoutState::insertGap(const QList<int> &path, QLayoutItem *item
 #ifndef QT_NO_TOOLBAR
     if (i == 0) {
         Q_ASSERT(qobject_cast<QToolBar*>(item->widget()) != 0);
+        qDebug() << __FUNCTION__ << "TB!";
         return toolBarAreaLayout.insertGap(path.mid(1), item);
     }
 #endif
 
 #ifndef QT_NO_DOCKWIDGET
     if (i == 1) {
+        qDebug() << __FUNCTION__ << "Dock";
         Q_ASSERT(qobject_cast<QDockWidget*>(item->widget()) || qobject_cast<QDockWidgetGroupWindow*>(item->widget()));
         return dockAreaLayout.insertGap(path.mid(1), item);
     }
@@ -1920,6 +1924,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));
@@ -1932,9 +1937,10 @@ void QMainWindowLayout::revert(QLayoutItem *widgetItem)
 
 bool QMainWindowLayout::plug(QLayoutItem *widgetItem)
 {
+    QWidget *widget = widgetItem->widget();
+    qDebug() << __FUNCTION__ << widget << "currentHoveredFloat=" << currentHoveredFloat;
 #ifndef QT_NO_DOCKWIDGET
     if (currentHoveredFloat) {
-        QWidget *widget = widgetItem->widget();
         QList<int> previousPath = layoutState.indexOf(widget);
         if (!previousPath.isEmpty())
             layoutState.remove(previousPath);
@@ -1948,6 +1954,7 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem)
         currentGapRect = QRect();
 
         if (QDockWidget *dropTo = qobject_cast<QDockWidget*>(currentHoveredFloat)) {
+            qDebug() << __FUNCTION__ << '1';
             //dropping to a normal widget, we mutate it in a QDockWidgetGroupWindow with two tabs
             QDockWidgetGroupWindow *floatingTabs = createTabbedDockWindow();
             floatingTabs->setGeometry(dropTo->geometry());
@@ -1965,6 +1972,7 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem)
             currentHoveredFloat = floatingTabs;
         }
 
+        qDebug() << __FUNCTION__ << '2';
         QDockWidgetGroupWindow *dwgw = qobject_cast<QDockWidgetGroupWindow *>(currentHoveredFloat);
         Q_ASSERT(dwgw);
         Q_ASSERT(dwgw->layoutInfo()->tabbed); // because floating group should always be tabbed
@@ -1973,19 +1981,24 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem)
             dwgw->layoutInfo()->remove(previousPath);
         dwgw->layoutInfo()->tab(0, widgetItem);
         QRect globalRect = dwgw->layoutInfo()->tabContentRect();
+        qDebug() <<  __FUNCTION__ << "globalRect=" << globalRect;
         globalRect.moveTopLeft(dwgw->mapToGlobal(globalRect.topLeft()));
+        qDebug() <<  __FUNCTION__ << "moved" << globalRect;
         pluggingWidget = widget;
         widgetAnimator.animate(widget, globalRect, dockOptions & QMainWindow::AnimatedDocks);
         return true;
     }
 #endif
+    qDebug() << __FUNCTION__  << "par=" << parentWidget();
 
-    if (!parentWidget()->isVisible() || parentWidget()->isMinimized() || currentGapPos.isEmpty())
+    if (!parentWidget()->isVisible() || parentWidget()->isMinimized() || currentGapPos.isEmpty()) {
+        qDebug() << __FUNCTION__ << '3' << 'f';
         return false;
+    }
 
     fixToolBarOrientation(widgetItem, currentGapPos.at(1));
 
-    QWidget *widget = widgetItem->widget();
+    // QWidget *widget = widgetItem->widget();
 
 #ifndef QT_NO_DOCKWIDGET
     // Let's remove the widget from any possible group window
@@ -2000,6 +2013,7 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem)
     QList<int> previousPath = layoutState.indexOf(widget);
 
     const QLayoutItem *it = layoutState.plug(currentGapPos);
+    qDebug() << __FUNCTION__ << '4' << it;
     if (!it)
         return false;
     Q_ASSERT(it == widgetItem);
@@ -2008,7 +2022,9 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem)
 
     pluggingWidget = widget;
     QRect globalRect = currentGapRect;
+    qDebug() << __FUNCTION__ << "globalRect=" <<globalRect;
     globalRect.moveTopLeft(parentWidget()->mapToGlobal(globalRect.topLeft()));
+    qDebug() << __FUNCTION__ << "moved globalRect=" <<globalRect;
 #ifndef QT_NO_DOCKWIDGET
     if (qobject_cast<QDockWidget*>(widget) != 0) {
         QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(widget->layout());
@@ -2019,6 +2035,7 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem)
             globalRect.adjust(-fw, -fw, fw, fw);
         }
     }
+        qDebug() << __FUNCTION__ << globalRect;
 #endif
     widgetAnimator.animate(widget, globalRect, dockOptions & QMainWindow::AnimatedDocks);
 
@@ -2027,6 +2044,7 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem)
 
 void QMainWindowLayout::animationFinished(QWidget *widget)
 {
+    qDebug() << __FUNCTION__ ;
     //this function is called from within the Widget Animator whenever an animation is finished
     //on a certain widget
 #ifndef QT_NO_TOOLBAR
@@ -2104,6 +2122,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
 #endif
 
         savedState.clear();
+        qDebug() << __FUNCTION__ << "currentGapPos.clear();";
         currentGapPos.clear();
         pluggingWidget = 0;
         currentHoveredFloat = Q_NULLPTR;
@@ -2139,6 +2158,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
 
 void QMainWindowLayout::restore(bool keepSavedState)
 {
+    qDebug() << __FUNCTION__ << keepSavedState;
     if (!savedState.isValid())
         return;
 
@@ -2146,6 +2166,7 @@ void QMainWindowLayout::restore(bool keepSavedState)
     applyState(layoutState);
     if (!keepSavedState)
         savedState.clear();
+    qDebug() << __FUNCTION__ << "currentGapPos.clear();";
     currentGapPos.clear();
     pluggingWidget = 0;
     updateGapIndicator();
@@ -2351,7 +2372,9 @@ void QMainWindowLayout::updateGapIndicator()
         } else if (gapIndicator->parent() != expectedParent) {
             gapIndicator->setParent(expectedParent);
         }
-        gapIndicator->setGeometry(currentHoveredFloat ? currentHoveredFloat->rect() : currentGapRect);
+        QRect r =  currentHoveredFloat ? currentHoveredFloat->rect() : currentGapRect;
+        gapIndicator->setGeometry(r);
+        qDebug() << __FUNCTION__ << "currentHoveredFloat=" << currentHoveredFloat << r;
         gapIndicator->show();
         gapIndicator->raise();
     } else if (gapIndicator) {
@@ -2362,9 +2385,14 @@ void QMainWindowLayout::updateGapIndicator()
 
 void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
 {
+    qDebug() << __FUNCTION__ << widgetItem->widget() << mousePos
+             << "par=" << parentWidget()
+             << "pluggingWidget=" << pluggingWidget;
     if (!parentWidget()->isVisible() || parentWidget()->isMinimized()
-        || pluggingWidget != 0 || widgetItem == 0)
+        || pluggingWidget != 0 || widgetItem == 0) {
+        qDebug() << __FUNCTION__ << "r1";
         return;
+    }
 
     QWidget *widget = widgetItem->widget();
 
@@ -2373,9 +2401,11 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
             || qobject_cast<QDockWidgetGroupWindow *>(widget))) {
 
         // Check if we are over another floating dock widget
+        qDebug() << __FUNCTION__ << "Check if we are over another floating dock widget";
         QVarLengthArray<QWidget *, 10> candidates;
         foreach (QObject *c, parentWidget()->children()) {
             QWidget *w = qobject_cast<QWidget*>(c);
+            qDebug() << __FUNCTION__ <<w;
             if (!w)
                 continue;
             if (!qobject_cast<QDockWidget*>(w) && !qobject_cast<QDockWidgetGroupWindow *>(w))
@@ -2397,10 +2427,15 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
             QWindow *handle2 = w->windowHandle();
             if (handle1 && handle2 && handle1->screen() != handle2->screen())
                 continue;
-            if (!w->geometry().contains(mousePos))
+            qDebug() << __FUNCTION__ << "checking cand" << w
+                     << w->geometry() << "for mousePos=" << mousePos;
+            if (!w->geometry().contains(mousePos)) {
+                qDebug() << "geom skip!";
                 continue;
+            }
 
             currentHoveredFloat = w;
+            qDebug() << "Calling restore currentHoveredFloat=" << currentHoveredFloat;
             restore(true);
             return;
         }
@@ -2409,6 +2444,8 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
 #endif //QT_NO_DOCKWIDGET
 
     QPoint pos = parentWidget()->mapFromGlobal(mousePos);
+    qDebug() << __FUNCTION__ << "lp" << parentWidget() << pos;
+
 
     if (!savedState.isValid())
         savedState = layoutState;
@@ -2434,12 +2471,17 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
             path.clear();
     }
 
-    if (path == currentGapPos)
+    qDebug() << __FUNCTION__ << "path=" << path << "currentGapPos=" << currentGapPos;
+    if (path == currentGapPos) {
+        qDebug() << __FUNCTION__ << "r path == currentGapPos";
         return; // the gap is already there
+    }
 
     currentGapPos = path;
+    qDebug() << __FUNCTION__ << "assigned currentGapPos = path";
     if (path.isEmpty()) {
         fixToolBarOrientation(widgetItem, 2); // 2 = top dock, ie. horizontal
+        qDebug() << "Calling restore path";
         restore(true);
         return;
     }
@@ -2449,6 +2491,7 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
     QMainWindowLayoutState newState = savedState;
 
     if (!newState.insertGap(path, widgetItem)) {
+        qDebug() << __FUNCTION__ << "calling restore not enough space r_newState.insertGap";
         restore(true); // not enough space
         return;
     }
@@ -2457,6 +2500,7 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
     QSize size = newState.rect.size();
 
     if (min.width() > size.width() || min.height() > size.height()) {
+        qDebug("res due to min");
         restore(true);
         return;
     }
@@ -2464,6 +2508,7 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
     newState.fitLayout();
 
     currentGapRect = newState.gapRect(currentGapPos);
+    qDebug() << __FUNCTION__ << "currentGapRect=" << currentGapRect;
 
 #ifndef QT_NO_DOCKWIDGET
     parentWidget()->update(layoutState.dockAreaLayout.separatorRegion());
diff --git a/src/widgets/widgets/qwidgetanimator.cpp b/src/widgets/widgets/qwidgetanimator.cpp
index a6aaddd..01ce5ae 100644
--- a/src/widgets/widgets/qwidgetanimator.cpp
+++ b/src/widgets/widgets/qwidgetanimator.cpp
@@ -35,7 +35,7 @@
 #include <QtWidgets/qwidget.h>
 #include <QtWidgets/qstyle.h>
 #include <private/qmainwindowlayout_p.h>
-
+#include <qdebug.h>
 #include "qwidgetanimator_p.h"
 
 QT_BEGIN_NAMESPACE
@@ -73,9 +73,12 @@ void QWidgetAnimator::animationFinished()
 
 void QWidgetAnimator::animate(QWidget *widget, const QRect &_final_geometry, bool animate)
 {
+    qDebug() << __FUNCTION__ << widget << _final_geometry;
     QRect r = widget->geometry();
-    if (r.right() < 0 || r.bottom() < 0)
+    if (r.right() < 0 || r.bottom() < 0) {
         r = QRect();
+        qDebug() << __FUNCTION__ << "r!";
+    }
 
     animate = animate && !r.isNull() && !_final_geometry.isNull();
 
