Fixed #594 - Destruction of CDockWidget inside a CFloatingDockContainer

This commit is contained in:
Uwe Kindler 2024-01-04 08:31:18 +01:00
parent 5b23248fb8
commit 7abc698d09

View File

@ -764,6 +764,31 @@ CFloatingDockContainer::CFloatingDockContainer(CDockWidget *DockWidget) :
CFloatingDockContainer::~CFloatingDockContainer() CFloatingDockContainer::~CFloatingDockContainer()
{ {
ADS_PRINT("~CFloatingDockContainer"); ADS_PRINT("~CFloatingDockContainer");
std::vector<QPointer<ads::CDockAreaWidget>> 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<QPointer<QWidget>> deleteWidgets;
for (auto widget : area->dockWidgets())
{
deleteWidgets.push_back(widget);
}
for (auto ptrWdg : deleteWidgets)
{
delete ptrWdg;
}
}
if (d->DockManager) if (d->DockManager)
{ {
d->DockManager->removeFloatingWidget(this); d->DockManager->removeFloatingWidget(this);