Skip to content

Fix 2 crashes in singleShot timers while undocking tabs (especially in auto hide mode)#792

Open
UnlimitedStack wants to merge 1 commit intogithubuser0xFFFF:masterfrom
UnlimitedStack:fix_crashes_in_singleshot_timers
Open

Fix 2 crashes in singleShot timers while undocking tabs (especially in auto hide mode)#792
UnlimitedStack wants to merge 1 commit intogithubuser0xFFFF:masterfrom
UnlimitedStack:fix_crashes_in_singleshot_timers

Conversation

@UnlimitedStack
Copy link

The first crash happens rarely while changing dock state programatically in startup phase.
The second one can be checked with the demo application. Just add the following line in the constructor of the demo:

CDockManager::setAutoHideConfigFlag(ads::CDockManager::AutoHideShowOnMouseOver, true);

Then attach a dock to the side bar (hide mode), select it and drag it anywhwere -> it crashes.

QObject::connect(&DelayedAutoHideTimer, &QTimer::timeout, [this](){
auto GlobalPos = DelayedAutoHideTab->mapToGlobal(QPoint(0, 0));
qApp->sendEvent(DelayedAutoHideTab, new QMouseEvent(QEvent::MouseButtonPress,
QObject::connect(&DelayedAutoHideTimer, &QTimer::timeout, [this](){
Copy link

Choose a reason for hiding this comment

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

This should be using DelayedAutoHideTab as receiver context-object on the connection. The inner if is then unnecessary.

QPointer<CDockAreaTabBar> __this = _this;
QPointer<CDockWidgetTab> __tabWidget = TabWidget;

QTimer::singleShot(0, TabWidget, [__this, __tabWidget]
Copy link

@Ext3h Ext3h Feb 16, 2026

Choose a reason for hiding this comment

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

Which of the two variables was ever able to able to become a nullptr?

Either way - specify this as context-object on the connection, the inner if on __this is redundant.

QPointer<CDockWidgetTab> __tabWidget is fine, but should be constructed directly in the lambda arg.

There's still the possible edge case that TabWidget has been reparented in the meantime, but that's supported properly by ensureWidgetVisible, it's a NOOP if the target isn't a child.

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.

2 participants

Comments