Skip to content

Commit 3969d28

Browse files
authored
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 (#307), the code from dockindock ends up deleting objects already deleted by parent.
1 parent b39cd2d commit 3969d28

File tree

1 file changed

+1
-26
lines changed

1 file changed

+1
-26
lines changed

examples/dockindock/dockindockmanager.cpp

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,6 @@ using namespace QtAdsUtl;
1515
/////////////////////////////////////
1616
// DockInDockManager
1717
/////////////////////////////////////
18-
void deleteAllChildrenToPreventLeak( ads::CDockContainerWidget* areaWidget )
19-
{
20-
// fix leaks: https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/issues/307
21-
22-
std::vector<ads::CDockAreaWidget*> areas;
23-
for ( int i = 0; i != areaWidget->dockAreaCount(); ++i )
24-
{
25-
areas.push_back( areaWidget->dockArea(i) );
26-
}
27-
28-
std::vector<std::string> deleted;
29-
for ( auto area : areas )
30-
{
31-
for ( auto widget : area->dockWidgets() )
32-
{
33-
ads::CDockContainerWidget* subArea = dynamic_cast<ads::CDockContainerWidget*>( widget->widget() );
34-
if ( subArea )
35-
deleteAllChildrenToPreventLeak( subArea );
36-
delete widget;
37-
}
38-
39-
delete area;
40-
}
41-
}
42-
4318
DockInDockManager::DockInDockManager( DockInDockWidget& parent ) :
4419
baseClass( &parent ),
4520
m_parent( parent )
@@ -49,7 +24,7 @@ DockInDockManager::DockInDockManager( DockInDockWidget& parent ) :
4924

5025
DockInDockManager::~DockInDockManager()
5126
{
52-
deleteAllChildrenToPreventLeak( this );
27+
5328
}
5429

5530
void DockInDockManager::fillViewMenu( QMenu* menu, const std::vector<DockInDockManager*>& moveTo )

0 commit comments

Comments
 (0)