From 3969d28d92b624a297a1b4e2147f1f4fb29ec0ba Mon Sep 17 00:00:00 2001 From: jporcher Date: Tue, 27 Apr 2021 11:16:09 +0200 Subject: [PATCH] Fix crash in dockindock (#317) * Add dockdepth1 example * Fix compilation (include assert.h) * Replace dockdepth1 by dockindock * Fix crash when dockindock example is closed. Due to code in dockindock supposed to fix memory leaks: now leaks were fixed in CDockManager (https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/issues/307), the code from dockindock ends up deleting objects already deleted by parent. --- examples/dockindock/dockindockmanager.cpp | 27 +---------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/examples/dockindock/dockindockmanager.cpp b/examples/dockindock/dockindockmanager.cpp index 1850185..160318c 100644 --- a/examples/dockindock/dockindockmanager.cpp +++ b/examples/dockindock/dockindockmanager.cpp @@ -15,31 +15,6 @@ using namespace QtAdsUtl; ///////////////////////////////////// // DockInDockManager ///////////////////////////////////// -void deleteAllChildrenToPreventLeak( ads::CDockContainerWidget* areaWidget ) -{ - // fix leaks: https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/issues/307 - - std::vector areas; - for ( int i = 0; i != areaWidget->dockAreaCount(); ++i ) - { - areas.push_back( areaWidget->dockArea(i) ); - } - - std::vector deleted; - for ( auto area : areas ) - { - for ( auto widget : area->dockWidgets() ) - { - ads::CDockContainerWidget* subArea = dynamic_cast( widget->widget() ); - if ( subArea ) - deleteAllChildrenToPreventLeak( subArea ); - delete widget; - } - - delete area; - } -} - DockInDockManager::DockInDockManager( DockInDockWidget& parent ) : baseClass( &parent ), m_parent( parent ) @@ -49,7 +24,7 @@ DockInDockManager::DockInDockManager( DockInDockWidget& parent ) : DockInDockManager::~DockInDockManager() { - deleteAllChildrenToPreventLeak( this ); + } void DockInDockManager::fillViewMenu( QMenu* menu, const std::vector& moveTo )