From 7abc698d099205b424ad89d7503040f55cc8df1e Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Thu, 4 Jan 2024 08:31:18 +0100 Subject: [PATCH] Fixed #594 - Destruction of CDockWidget inside a CFloatingDockContainer --- src/FloatingDockContainer.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/FloatingDockContainer.cpp b/src/FloatingDockContainer.cpp index 2ebf4a5..87f4053 100644 --- a/src/FloatingDockContainer.cpp +++ b/src/FloatingDockContainer.cpp @@ -764,6 +764,31 @@ CFloatingDockContainer::CFloatingDockContainer(CDockWidget *DockWidget) : CFloatingDockContainer::~CFloatingDockContainer() { ADS_PRINT("~CFloatingDockContainer"); + std::vector> areas; + for (int i = 0; i != dockContainer()->dockAreaCount(); ++i) + { + areas.push_back( dockContainer()->dockArea(i) ); + } + for (auto area : areas) + { + if (!area) + { + continue; + } + + // QPointer delete safety - just in case some dock wigdet in destruction + // deletes another related/twin or child dock widget. + std::vector> deleteWidgets; + for (auto widget : area->dockWidgets()) + { + deleteWidgets.push_back(widget); + } + for (auto ptrWdg : deleteWidgets) + { + delete ptrWdg; + } + } + if (d->DockManager) { d->DockManager->removeFloatingWidget(this);