Skip to content

Commit df74686

Browse files
authored
call CDockWidget::closeDockWidgetInternal when close attempt and CustomCloseHandling (#438)
Co-authored-by: bjb-work <N/A>
1 parent 75d58b3 commit df74686

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/DockAreaWidget.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ void CDockAreaWidget::onTabCloseRequested(int Index)
538538
{
539539
ADS_PRINT("CDockAreaWidget::onTabCloseRequested " << Index);
540540
auto* DockWidget = dockWidget(Index);
541-
if (DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose))
541+
if (DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose) || DockWidget->features().testFlag(CDockWidget::CustomCloseHandling))
542542
{
543543
DockWidget->closeDockWidgetInternal();
544544
}
@@ -956,17 +956,21 @@ QAbstractButton* CDockAreaWidget::titleBarButton(TitleBarButton which) const
956956
void CDockAreaWidget::closeArea()
957957
{
958958
// If there is only one single dock widget and this widget has the
959-
// DeleteOnClose feature, then we delete the dock widget now
959+
// DeleteOnClose feature or CustomCloseHandling, then we delete the dock widget now;
960+
// in the case of CustomCloseHandling, the CDockWidget class will emit its
961+
// closeRequested signal and not actually delete unless the signal is handled in a way that deletes it
960962
auto OpenDockWidgets = openedDockWidgets();
961-
if (OpenDockWidgets.count() == 1 && OpenDockWidgets[0]->features().testFlag(CDockWidget::DockWidgetDeleteOnClose))
963+
if (OpenDockWidgets.count() == 1 &&
964+
(OpenDockWidgets[0]->features().testFlag(CDockWidget::DockWidgetDeleteOnClose) || OpenDockWidgets[0]->features().testFlag(CDockWidget::CustomCloseHandling)))
962965
{
963966
OpenDockWidgets[0]->closeDockWidgetInternal();
964967
}
965968
else
966969
{
967970
for (auto DockWidget : openedDockWidgets())
968971
{
969-
if (DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose) && DockWidget->features().testFlag(CDockWidget::DockWidgetForceCloseWithArea))
972+
if ((DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose) && DockWidget->features().testFlag(CDockWidget::DockWidgetForceCloseWithArea)) ||
973+
DockWidget->features().testFlag(CDockWidget::CustomCloseHandling))
970974
DockWidget->closeDockWidgetInternal();
971975
else
972976
DockWidget->toggleView(false);

src/FloatingDockContainer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ void CFloatingDockContainer::closeEvent(QCloseEvent *event)
809809

810810
for (auto DockWidget : d->DockContainer->openedDockWidgets())
811811
{
812-
if (DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose))
812+
if (DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose) || DockWidget->features().testFlag(CDockWidget::CustomCloseHandling))
813813
{
814814
DockWidget->closeDockWidgetInternal();
815815
}

0 commit comments

Comments
 (0)