From 427b5a0be09e66c1faae30462f52b7d2992edb84 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Thu, 14 May 2020 07:20:30 +0200 Subject: [PATCH] Added nullptr check to fix potential issue #171 - nullptr access closing a CFloatingDockContainer --- src/FloatingDockContainer.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/FloatingDockContainer.cpp b/src/FloatingDockContainer.cpp index c5bab75..18e7bfa 100644 --- a/src/FloatingDockContainer.cpp +++ b/src/FloatingDockContainer.cpp @@ -68,6 +68,7 @@ struct FloatingDockContainerPrivate CDockContainerWidget *DropContainer = nullptr; CDockAreaWidget *SingleDockArea = nullptr; QPoint DragStartPos; + bool Hiding = false; #ifdef Q_OS_LINUX QWidget* MouseEventHandler = nullptr; CFloatingWidgetTitleBar* TitleBar = nullptr; @@ -455,6 +456,7 @@ void CFloatingDockContainer::hideEvent(QHideEvent *event) return; } + d->Hiding = true; for (auto DockArea : d->DockContainer->openedDockAreas()) { for (auto DockWidget : DockArea->openedDockWidgets()) @@ -462,6 +464,7 @@ void CFloatingDockContainer::hideEvent(QHideEvent *event) DockWidget->toggleView(false); } } + d->Hiding = false; } //============================================================================ @@ -652,11 +655,22 @@ void CFloatingDockContainer::onDockAreasAddedOrRemoved() //============================================================================ void CFloatingDockContainer::updateWindowTitle() { + // If this floating container will be hidden, then updating the window + // tile is not required anymore + if (d->Hiding) + { + return; + } + + auto TopLevelDockArea = d->DockContainer->topLevelDockArea(); if (TopLevelDockArea) { CDockWidget* CurrentWidget = TopLevelDockArea->currentDockWidget(); - d->reflectCurrentWidget(CurrentWidget); + if (CurrentWidget) + { + d->reflectCurrentWidget(CurrentWidget); + } } else {