Skip to content

Commit bfe6b9b

Browse files
Merge branch 'FixesPack_Parenting_Memory_leaks_etc' of https://github.com/ymiroshnyk/Qt-Advanced-Docking-System into ymiroshnyk-FixesPack_Parenting_Memory_leaks_etc
2 parents 6d9c4ce + a565239 commit bfe6b9b

File tree

3 files changed

+9
-23
lines changed

3 files changed

+9
-23
lines changed

src/DockAreaWidget.cpp

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,6 @@ class CDockAreaLayout
8686

8787
}
8888

89-
/**
90-
* Delete widgets without parents in this layout
91-
*/
92-
~CDockAreaLayout()
93-
{
94-
for(auto Widget : m_Widgets)
95-
{
96-
if(!Widget->parent())
97-
delete Widget;
98-
}
99-
}
100-
10189
/**
10290
* Returns the number of widgets in this layout
10391
*/
@@ -112,7 +100,6 @@ class CDockAreaLayout
112100
*/
113101
void insertWidget(int index, QWidget* Widget)
114102
{
115-
Widget->setParent(nullptr);
116103
if (index < 0)
117104
{
118105
index = m_Widgets.count();
@@ -143,6 +130,8 @@ class CDockAreaLayout
143130
{
144131
LayoutItem->widget()->setParent(nullptr);
145132
}
133+
delete LayoutItem;
134+
146135
m_CurrentWidget = nullptr;
147136
m_CurrentIndex = -1;
148137
}
@@ -182,11 +171,7 @@ class CDockAreaLayout
182171
parent->setUpdatesEnabled(false);
183172
}
184173

185-
auto LayoutItem = m_ParentLayout->takeAt(1);
186-
if (LayoutItem)
187-
{
188-
LayoutItem->widget()->setParent(nullptr);
189-
}
174+
delete m_ParentLayout->takeAt(1);
190175

191176
m_ParentLayout->addWidget(next);
192177
if (prev)
@@ -247,7 +232,7 @@ class CDockAreaLayout
247232

248233

249234
using DockAreaLayout = CDockAreaLayout;
250-
static constexpr DockWidgetAreas DefaultAllowedAreas = AllDockAreas;
235+
static const DockWidgetAreas DefaultAllowedAreas = AllDockAreas;
251236

252237

253238
/**

src/DockManager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,11 @@ bool DockManagerPrivate::restoreStateFromXml(const QByteArray &state, int versi
296296
{
297297
// Delete remaining empty floating widgets
298298
int FloatingWidgetIndex = DockContainerCount - 1;
299-
int DeleteCount = FloatingWidgets.count() - FloatingWidgetIndex;
300-
for (int i = 0; i < DeleteCount; ++i)
299+
for (int i = FloatingWidgetIndex; i < FloatingWidgets.count(); ++i)
301300
{
302-
FloatingWidgets[FloatingWidgetIndex + i]->deleteLater();
303-
_this->removeDockContainer(FloatingWidgets[FloatingWidgetIndex + i]->dockContainer());
301+
auto* floatingWidget = FloatingWidgets[i];
302+
_this->removeDockContainer(floatingWidget->dockContainer());
303+
floatingWidget->deleteLater();
304304
}
305305
}
306306

src/DockWidget.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ void CDockWidget::setDockArea(CDockAreaWidget* DockArea)
542542
{
543543
d->DockArea = DockArea;
544544
d->ToggleViewAction->setChecked(DockArea != nullptr && !this->isClosed());
545+
setParent(DockArea);
545546
}
546547

547548

0 commit comments

Comments
 (0)