mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 07:31:33 +08:00
Fixes pack. Parenting, memory leaks, floating widgets deleting.
* DockWidget always has DockAreaWidget as parent. It's not necessary to make it nullptr. This fixes many bugs related to restoring inactive tabbed DockWidgets. * Fixed memory leaks related to QBoxLayout::takeAt(). * Fixed algorithm of deleting remaining floating widgets after restore.
This commit is contained in:
parent
703a9b3e12
commit
a565239c4a
@ -86,18 +86,6 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete widgets without parents in this layout
|
|
||||||
*/
|
|
||||||
~CDockAreaLayout()
|
|
||||||
{
|
|
||||||
for(auto Widget : m_Widgets)
|
|
||||||
{
|
|
||||||
if(!Widget->parent())
|
|
||||||
delete Widget;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of widgets in this layout
|
* Returns the number of widgets in this layout
|
||||||
*/
|
*/
|
||||||
@ -112,7 +100,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
void insertWidget(int index, QWidget* Widget)
|
void insertWidget(int index, QWidget* Widget)
|
||||||
{
|
{
|
||||||
Widget->setParent(nullptr);
|
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
{
|
{
|
||||||
index = m_Widgets.count();
|
index = m_Widgets.count();
|
||||||
@ -143,6 +130,8 @@ public:
|
|||||||
{
|
{
|
||||||
LayoutItem->widget()->setParent(nullptr);
|
LayoutItem->widget()->setParent(nullptr);
|
||||||
}
|
}
|
||||||
|
delete LayoutItem;
|
||||||
|
|
||||||
m_CurrentWidget = nullptr;
|
m_CurrentWidget = nullptr;
|
||||||
m_CurrentIndex = -1;
|
m_CurrentIndex = -1;
|
||||||
}
|
}
|
||||||
@ -182,11 +171,7 @@ public:
|
|||||||
parent->setUpdatesEnabled(false);
|
parent->setUpdatesEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto LayoutItem = m_ParentLayout->takeAt(1);
|
delete m_ParentLayout->takeAt(1);
|
||||||
if (LayoutItem)
|
|
||||||
{
|
|
||||||
LayoutItem->widget()->setParent(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_ParentLayout->addWidget(next);
|
m_ParentLayout->addWidget(next);
|
||||||
if (prev)
|
if (prev)
|
||||||
@ -247,7 +232,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
using DockAreaLayout = CDockAreaLayout;
|
using DockAreaLayout = CDockAreaLayout;
|
||||||
static constexpr DockWidgetAreas DefaultAllowedAreas = AllDockAreas;
|
static const DockWidgetAreas DefaultAllowedAreas = AllDockAreas;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -296,11 +296,11 @@ bool DockManagerPrivate::restoreStateFromXml(const QByteArray &state, int versi
|
|||||||
{
|
{
|
||||||
// Delete remaining empty floating widgets
|
// Delete remaining empty floating widgets
|
||||||
int FloatingWidgetIndex = DockContainerCount - 1;
|
int FloatingWidgetIndex = DockContainerCount - 1;
|
||||||
int DeleteCount = FloatingWidgets.count() - FloatingWidgetIndex;
|
for (int i = FloatingWidgetIndex; i < FloatingWidgets.count(); ++i)
|
||||||
for (int i = 0; i < DeleteCount; ++i)
|
|
||||||
{
|
{
|
||||||
FloatingWidgets[FloatingWidgetIndex + i]->deleteLater();
|
auto* floatingWidget = FloatingWidgets[i];
|
||||||
_this->removeDockContainer(FloatingWidgets[FloatingWidgetIndex + i]->dockContainer());
|
_this->removeDockContainer(floatingWidget->dockContainer());
|
||||||
|
floatingWidget->deleteLater();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -542,6 +542,7 @@ void CDockWidget::setDockArea(CDockAreaWidget* DockArea)
|
|||||||
{
|
{
|
||||||
d->DockArea = DockArea;
|
d->DockArea = DockArea;
|
||||||
d->ToggleViewAction->setChecked(DockArea != nullptr && !this->isClosed());
|
d->ToggleViewAction->setChecked(DockArea != nullptr && !this->isClosed());
|
||||||
|
setParent(DockArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user