From 07355fa5b290723300d7f6cd351fc8867ec613c9 Mon Sep 17 00:00:00 2001 From: Syarif Fakhri Date: Wed, 2 Nov 2022 12:40:45 +0800 Subject: [PATCH] change fix for crash on currentIndex invalid --- src/AutoHideDockContainer.cpp | 3 ++- src/DockContainerWidget.cpp | 5 ----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/AutoHideDockContainer.cpp b/src/AutoHideDockContainer.cpp index 6256b78..4f91149 100644 --- a/src/AutoHideDockContainer.cpp +++ b/src/AutoHideDockContainer.cpp @@ -311,7 +311,8 @@ void CAutoHideDockContainer::addDockWidget(CDockWidget* DockWidget) d->DockWidget = DockWidget; d->SideTab->setDockWidget(DockWidget); CDockAreaWidget* OldDockArea = DockWidget->dockAreaWidget(); - if (OldDockArea) + // Don't remove dock widgets while restoring state, the current index pointer may be invalid + if (!DockWidget->dockManager()->isRestoringState() && OldDockArea) { OldDockArea->removeDockWidget(DockWidget); } diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index ee71d21..459b166 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -1089,11 +1089,6 @@ bool DockContainerWidgetPrivate::restoreSideBar(CDockingStateReader& s, { continue; } - const auto oldDockArea = DockWidget->dockAreaWidget(); - if (oldDockArea) - { - oldDockArea->removeDockWidget(DockWidget); - } auto SideBar = _this->sideTabBar(Area); auto AutoHideContainer = SideBar->insertDockWidget(-1, DockWidget);