mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-11-15 13:15:43 +08:00
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:
parent
b39cd2d81b
commit
3969d28d92
@ -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 )
|
||||
|
Loading…
Reference in New Issue
Block a user