1
0
mirror of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git synced 2025-03-15 10:39:51 +08:00

Added nullptr check to fix potential issue #171 - nullptr access closing a CFloatingDockContainer

This commit is contained in:
Uwe Kindler 2020-05-14 07:20:30 +02:00
parent 3011c0c030
commit 427b5a0be0

View File

@ -68,6 +68,7 @@ struct FloatingDockContainerPrivate
CDockContainerWidget *DropContainer = nullptr; CDockContainerWidget *DropContainer = nullptr;
CDockAreaWidget *SingleDockArea = nullptr; CDockAreaWidget *SingleDockArea = nullptr;
QPoint DragStartPos; QPoint DragStartPos;
bool Hiding = false;
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
QWidget* MouseEventHandler = nullptr; QWidget* MouseEventHandler = nullptr;
CFloatingWidgetTitleBar* TitleBar = nullptr; CFloatingWidgetTitleBar* TitleBar = nullptr;
@ -455,6 +456,7 @@ void CFloatingDockContainer::hideEvent(QHideEvent *event)
return; return;
} }
d->Hiding = true;
for (auto DockArea : d->DockContainer->openedDockAreas()) for (auto DockArea : d->DockContainer->openedDockAreas())
{ {
for (auto DockWidget : DockArea->openedDockWidgets()) for (auto DockWidget : DockArea->openedDockWidgets())
@ -462,6 +464,7 @@ void CFloatingDockContainer::hideEvent(QHideEvent *event)
DockWidget->toggleView(false); DockWidget->toggleView(false);
} }
} }
d->Hiding = false;
} }
//============================================================================ //============================================================================
@ -652,12 +655,23 @@ void CFloatingDockContainer::onDockAreasAddedOrRemoved()
//============================================================================ //============================================================================
void CFloatingDockContainer::updateWindowTitle() 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(); auto TopLevelDockArea = d->DockContainer->topLevelDockArea();
if (TopLevelDockArea) if (TopLevelDockArea)
{ {
CDockWidget* CurrentWidget = TopLevelDockArea->currentDockWidget(); CDockWidget* CurrentWidget = TopLevelDockArea->currentDockWidget();
if (CurrentWidget)
{
d->reflectCurrentWidget(CurrentWidget); d->reflectCurrentWidget(CurrentWidget);
} }
}
else else
{ {
d->setWindowTitle(qApp->applicationDisplayName()); d->setWindowTitle(qApp->applicationDisplayName());