diff --git a/src/DockManager.cpp b/src/DockManager.cpp index 5d47394..06ed8cd 100644 --- a/src/DockManager.cpp +++ b/src/DockManager.cpp @@ -566,6 +566,7 @@ CDockManager::~CDockManager() auto FloatingWidgets = d->FloatingWidgets; for (auto FloatingWidget : FloatingWidgets) { + FloatingWidget->deleteContent(); delete FloatingWidget; } diff --git a/src/FloatingDockContainer.cpp b/src/FloatingDockContainer.cpp index f228476..e06e131 100644 --- a/src/FloatingDockContainer.cpp +++ b/src/FloatingDockContainer.cpp @@ -760,10 +760,22 @@ CFloatingDockContainer::CFloatingDockContainer(CDockWidget *DockWidget) : d->DockManager->notifyWidgetOrAreaRelocation(DockWidget); } + //============================================================================ CFloatingDockContainer::~CFloatingDockContainer() { ADS_PRINT("~CFloatingDockContainer"); + if (d->DockManager) + { + d->DockManager->removeFloatingWidget(this); + } + delete d; +} + + +//============================================================================ +void CFloatingDockContainer::deleteContent() +{ std::vector> areas; for (int i = 0; i != dockContainer()->dockAreaCount(); ++i) { @@ -788,12 +800,6 @@ CFloatingDockContainer::~CFloatingDockContainer() delete ptrWdg; } } - - if (d->DockManager) - { - d->DockManager->removeFloatingWidget(this); - } - delete d; } //============================================================================ diff --git a/src/FloatingDockContainer.h b/src/FloatingDockContainer.h index 2622767..7e6faec 100644 --- a/src/FloatingDockContainer.h +++ b/src/FloatingDockContainer.h @@ -146,6 +146,13 @@ protected: */ virtual void finishDragging() override; + /** + * This function deletes all dock widgets in it. + * This functions should be called only from dock manager in its + * destructor before deleting the floating widget + */ + void deleteContent(); + /** * Call this function if you just want to initialize the position * and size of the floating widget