Skip to content

Remove dangling pointer to tab widget when removing an autohide widget #740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2025

Conversation

pylessard
Copy link

Would fix #739
Tested locally. Results below

image

I am still unsure wether DockWidget::isAutoHide() should query the dockArea.

Also, I find it a bit weird that the pointer is assigned by CAutoHideSideBar but removed by AutoHideDockContainer. But looking at the call graph, every one calls the CAutoHideDockContainer::cleanupAndDelete function while CAutoHideSideBar.removeAutoHideWidget is only called when a tab moves from one sidebar to another.

@githubuser0xFFFF githubuser0xFFFF requested a review from Copilot May 3, 2025 01:06
@githubuser0xFFFF githubuser0xFFFF self-assigned this May 3, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses the removal of a dangling pointer to the tab widget when an auto-hide widget is removed.

  • Clears the side-tab widget pointer in the dock widget via setSideTabWidget(nullptr).
  • Removes and detaches the SideTab from its parent container.
Comments suppressed due to low confidence (1)

src/AutoHideDockContainer.cpp:428

  • [nitpick] Consider renaming the variable 'SideTab' to follow consistent naming conventions (e.g. 'sideTab') used in the project.
auto SideTab = d->SideTab;

@@ -425,8 +425,8 @@ void CAutoHideDockContainer::cleanupAndDelete()
const auto dockWidget = d->DockWidget;
if (dockWidget)
{

auto SideTab = d->SideTab;
Copy link
Preview

Copilot AI May 3, 2025

Choose a reason for hiding this comment

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

[nitpick] Adding a short comment to highlight that clearing the pointer prevents a dangling reference could improve code clarity and future maintenance.

Suggested change
auto SideTab = d->SideTab;
auto SideTab = d->SideTab;
// Clear the pointer to prevent a dangling reference after the SideTab is removed.

Copilot uses AI. Check for mistakes.

@githubuser0xFFFF
Copy link
Owner

Thank your for this fix

@githubuser0xFFFF githubuser0xFFFF merged commit 4e90a38 into githubuser0xFFFF:master May 8, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Moving a dockwidget from autohide to floating leaves isAutoHide() true
2 participants