Skip to content

Commit 427b5a0

Browse files
Added nullptr check to fix potential issue #171 - nullptr access closing a CFloatingDockContainer
1 parent 3011c0c commit 427b5a0

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/FloatingDockContainer.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ struct FloatingDockContainerPrivate
6868
CDockContainerWidget *DropContainer = nullptr;
6969
CDockAreaWidget *SingleDockArea = nullptr;
7070
QPoint DragStartPos;
71+
bool Hiding = false;
7172
#ifdef Q_OS_LINUX
7273
QWidget* MouseEventHandler = nullptr;
7374
CFloatingWidgetTitleBar* TitleBar = nullptr;
@@ -455,13 +456,15 @@ void CFloatingDockContainer::hideEvent(QHideEvent *event)
455456
return;
456457
}
457458

459+
d->Hiding = true;
458460
for (auto DockArea : d->DockContainer->openedDockAreas())
459461
{
460462
for (auto DockWidget : DockArea->openedDockWidgets())
461463
{
462464
DockWidget->toggleView(false);
463465
}
464466
}
467+
d->Hiding = false;
465468
}
466469

467470
//============================================================================
@@ -652,11 +655,22 @@ void CFloatingDockContainer::onDockAreasAddedOrRemoved()
652655
//============================================================================
653656
void CFloatingDockContainer::updateWindowTitle()
654657
{
658+
// If this floating container will be hidden, then updating the window
659+
// tile is not required anymore
660+
if (d->Hiding)
661+
{
662+
return;
663+
}
664+
665+
655666
auto TopLevelDockArea = d->DockContainer->topLevelDockArea();
656667
if (TopLevelDockArea)
657668
{
658669
CDockWidget* CurrentWidget = TopLevelDockArea->currentDockWidget();
659-
d->reflectCurrentWidget(CurrentWidget);
670+
if (CurrentWidget)
671+
{
672+
d->reflectCurrentWidget(CurrentWidget);
673+
}
660674
}
661675
else
662676
{

0 commit comments

Comments
 (0)