diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index 0868c86..53bdd1b 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -1565,8 +1565,9 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi } if (Dropped) - { - FloatingWidget->deleteLater(); + { + // Fix https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/issues/351 + FloatingWidget->hideAndDeleteLater(); // 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 diff --git a/src/FloatingDockContainer.cpp b/src/FloatingDockContainer.cpp index 69d4aa0..ceb308a 100644 --- a/src/FloatingDockContainer.cpp +++ b/src/FloatingDockContainer.cpp @@ -373,6 +373,7 @@ struct FloatingDockContainerPrivate CDockAreaWidget *SingleDockArea = nullptr; QPoint DragStartPos; bool Hiding = false; + bool AutoHideChildren = true; #ifdef Q_OS_LINUX QWidget* MouseEventHandler = nullptr; CFloatingWidgetTitleBar* TitleBar = nullptr; @@ -841,15 +842,18 @@ void CFloatingDockContainer::hideEvent(QHideEvent *event) return; } - d->Hiding = true; - for (auto DockArea : d->DockContainer->openedDockAreas()) + if ( d->AutoHideChildren ) { - for (auto DockWidget : DockArea->openedDockWidgets()) + d->Hiding = true; + for ( auto DockArea : d->DockContainer->openedDockAreas() ) { - DockWidget->toggleView(false); + for ( auto DockWidget : DockArea->openedDockWidgets() ) + { + DockWidget->toggleView( false ); + } } + d->Hiding = false; } - d->Hiding = false; } @@ -1035,6 +1039,18 @@ QList CFloatingDockContainer::dockWidgets() const return d->DockContainer->dockWidgets(); } +//============================================================================ +void CFloatingDockContainer::hideAndDeleteLater() +{ + // Widget has been redocked, so it must be hidden right way (see + // https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/issues/351) + // but AutoHideChildren must be set to false because "this" still contains + // dock widgets that shall not be toggled hidden. + d->AutoHideChildren = false; + hide(); + deleteLater(); +} + //============================================================================ void CFloatingDockContainer::finishDragging() { diff --git a/src/FloatingDockContainer.h b/src/FloatingDockContainer.h index 559cf2f..39025b5 100644 --- a/src/FloatingDockContainer.h +++ b/src/FloatingDockContainer.h @@ -258,6 +258,11 @@ public: */ QList dockWidgets() const; + /** + * This function hides the floating bar instantely and delete it later. + */ + void hideAndDeleteLater(); + #ifdef Q_OS_LINUX /** * This is a function that responds to FloatingWidgetTitleBar::maximizeRequest()