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.
This commit is contained in:
jporcher 2021-04-27 11:16:09 +02:00 committed by GitHub
parent b39cd2d81b
commit 3969d28d92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<ads::CDockAreaWidget*> areas;
for ( int i = 0; i != areaWidget->dockAreaCount(); ++i )
{
areas.push_back( areaWidget->dockArea(i) );
}
std::vector<std::string> deleted;
for ( auto area : areas )
{
for ( auto widget : area->dockWidgets() )
{
ads::CDockContainerWidget* subArea = dynamic_cast<ads::CDockContainerWidget*>( 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<DockInDockManager*>& moveTo )