Skip to content

Unbind containers from DockManager to prevent accidental reuse#823

Open
Ext3h wants to merge 1 commit intogithubuser0xFFFF:masterfrom
Ext3h:unexpected-container-reuse
Open

Unbind containers from DockManager to prevent accidental reuse#823
Ext3h wants to merge 1 commit intogithubuser0xFFFF:masterfrom
Ext3h:unexpected-container-reuse

Conversation

@Ext3h
Copy link

@Ext3h Ext3h commented Mar 17, 2026

When explicitly removing container widget externally (eventually ending up in CDockAreaWidget::removeDockWidget), there's a short time frame in which the old container was not removed from the CDockManager yet, but already marked as deleteLater.

This results in possible reuse of the already-to-be-deleted-container by CDockManager when immediately adding new container widgets before the deleteLater has come into effect.

In order to fix this:

  • Eager de-registration from CDockManager in CDockAreaWidget::removeDockWidget
  • Explicitly break up the link from already orphaned CFloatingDockContainer and CDockContainerWidget back to CDockManager to avoid further side effects.

#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
QWidget* MouseEventHandler = nullptr;
CFloatingWidgetTitleBar* TitleBar = nullptr;
CDockAreaWidget *SingleDockArea = nullptr;
Copy link
Author

@Ext3h Ext3h Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bbde511 had introduced inconsistent line endings. This repository does not appear to be using AUTOCLRF nor specify LineEnding in .clang-format, so that's likely to happen again...

{
FloatingDockContainer->hide();
FloatingDockContainer->deleteLater();
FloatingDockContainer->finishDropOperation();
Copy link
Author

@Ext3h Ext3h Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hideAndDeleteLater has been recently renamed to finishDropOperation, but its functionality isn't just required for drop-operations.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should be renamed to close() or teardown().

friend CAutoHideSideBar;

private Q_SLOTS:
void removeFromDockManager();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name may be realigned with CFloatingDockContainer::finishDropOperation

// of the floating widget does not delete any dock areas that have been
// moved to a new container - simply remove all dock areas before deleting
// the floating widget
d->DockContainer->removeAllDockAreas();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we now have a dedicated teardown method in CDockContainerWidget, this internal call should be moved there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant