From 45af8867b24a5271fd02a6e8c14abb244b746651 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Tue, 10 Dec 2019 12:47:55 +0100 Subject: [PATCH] Fixed debug output, moved all calls to FloatingWidget->deleteLater() to a centra place in CDockContainerWidget::dropFloatingWidget --- src/DockAreaTabBar.cpp | 2 +- src/DockContainerWidget.cpp | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/DockAreaTabBar.cpp b/src/DockAreaTabBar.cpp index a89c82a..5ec6d9e 100644 --- a/src/DockAreaTabBar.cpp +++ b/src/DockAreaTabBar.cpp @@ -172,7 +172,7 @@ void CDockAreaTabBar::mouseReleaseEvent(QMouseEvent* ev) { if (ev->button() == Qt::LeftButton) { - ADS_PRINT("CTabsScrollArea::mouseReleaseEvent"); + ADS_PRINT("CDockAreaTabBar::mouseReleaseEvent"); ev->accept(); d->FloatingWidget = nullptr; d->DragStartMousePos = QPoint(); diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index 94af7a3..790c5b6 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -427,7 +427,6 @@ void DockContainerWidgetPrivate::dropIntoContainer(CFloatingDockContainer* Float RootSplitter = Splitter; addDockAreasToList(NewDockAreas); - FloatingWidget->deleteLater(); // If we dropped the floating widget into the main dock container that does // not contain any dock widgets, then splitter is invisible and we need to @@ -470,7 +469,6 @@ void DockContainerWidgetPrivate::dropIntoCenterOfSection( } } TargetArea->setCurrentIndex(NewCurrentIndex); - FloatingWidget->deleteLater(); TargetArea->updateTitleBarVisibility(); return; } @@ -563,7 +561,6 @@ void DockContainerWidgetPrivate::dropIntoSection(CFloatingDockContainer* Floatin TargetAreaSplitter->setSizes(Sizes); } - FloatingWidget->deleteLater(); addDockAreasToList(NewDockAreas); _this->dumpLayout(); } @@ -1390,6 +1387,7 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi CDockAreaWidget* DockArea = dockAreaAt(TargetPos); auto dropArea = InvalidDockWidgetArea; auto ContainerDropArea = d->DockManager->containerOverlay()->dropAreaUnderCursor(); + bool Dropped = false; if (DockArea) { @@ -1406,6 +1404,7 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi { ADS_PRINT("Dock Area Drop Content: " << dropArea); d->dropIntoSection(FloatingWidget, DockArea, dropArea); + Dropped = true; } } @@ -1417,16 +1416,22 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi if (dropArea != InvalidDockWidgetArea) { d->dropIntoContainer(FloatingWidget, dropArea); + Dropped = true; } } - // If we dropped a floating widget with only one single dock widget, then we - // drop a top level widget that changes from floating to docked now - CDockWidget::emitTopLevelEventForWidget(SingleDroppedDockWidget, false); + if (Dropped) + { + FloatingWidget->deleteLater(); - // If there was a top level widget before the drop, then it is not top - // level widget anymore - CDockWidget::emitTopLevelEventForWidget(SingleDockWidget, false); + // If we dropped a floating widget with only one single dock widget, then we + // drop a top level widget that changes from floating to docked now + CDockWidget::emitTopLevelEventForWidget(SingleDroppedDockWidget, false); + + // If there was a top level widget before the drop, then it is not top + // level widget anymore + CDockWidget::emitTopLevelEventForWidget(SingleDockWidget, false); + } }