diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index 78c4e5e..eaf99ad 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -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 */ @@ -112,7 +100,6 @@ public: */ void insertWidget(int index, QWidget* Widget) { - Widget->setParent(nullptr); if (index < 0) { index = m_Widgets.count(); @@ -143,6 +130,8 @@ public: { LayoutItem->widget()->setParent(nullptr); } + delete LayoutItem; + m_CurrentWidget = nullptr; m_CurrentIndex = -1; } @@ -182,11 +171,7 @@ public: parent->setUpdatesEnabled(false); } - auto LayoutItem = m_ParentLayout->takeAt(1); - if (LayoutItem) - { - LayoutItem->widget()->setParent(nullptr); - } + delete m_ParentLayout->takeAt(1); m_ParentLayout->addWidget(next); if (prev) @@ -247,7 +232,7 @@ public: using DockAreaLayout = CDockAreaLayout; -static constexpr DockWidgetAreas DefaultAllowedAreas = AllDockAreas; +static const DockWidgetAreas DefaultAllowedAreas = AllDockAreas; /** diff --git a/src/DockManager.cpp b/src/DockManager.cpp index f75ff71..09bc9a5 100644 --- a/src/DockManager.cpp +++ b/src/DockManager.cpp @@ -296,11 +296,11 @@ bool DockManagerPrivate::restoreStateFromXml(const QByteArray &state, int versi { // Delete remaining empty floating widgets int FloatingWidgetIndex = DockContainerCount - 1; - int DeleteCount = FloatingWidgets.count() - FloatingWidgetIndex; - for (int i = 0; i < DeleteCount; ++i) + for (int i = FloatingWidgetIndex; i < FloatingWidgets.count(); ++i) { - FloatingWidgets[FloatingWidgetIndex + i]->deleteLater(); - _this->removeDockContainer(FloatingWidgets[FloatingWidgetIndex + i]->dockContainer()); + auto* floatingWidget = FloatingWidgets[i]; + _this->removeDockContainer(floatingWidget->dockContainer()); + floatingWidget->deleteLater(); } } diff --git a/src/DockWidget.cpp b/src/DockWidget.cpp index 83cb613..dceca83 100644 --- a/src/DockWidget.cpp +++ b/src/DockWidget.cpp @@ -542,6 +542,7 @@ void CDockWidget::setDockArea(CDockAreaWidget* DockArea) { d->DockArea = DockArea; d->ToggleViewAction->setChecked(DockArea != nullptr && !this->isClosed()); + setParent(DockArea); }