Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/DockAreaTabBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <QApplication>
#include <QtGlobal>
#include <QTimer>
#include <QPointer>

#include "FloatingDockContainer.h"
#include "DockAreaWidget.h"
Expand Down Expand Up @@ -111,9 +112,15 @@ void DockAreaTabBarPrivate::updateTabs()
// Sometimes the synchronous calculation of the rectangular area fails
// Therefore we use QTimer::singleShot here to execute the call
// within the event loop - see #520
QTimer::singleShot(0, _this, [&, TabWidget]
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.

{
_this->ensureWidgetVisible(TabWidget);
if (__this && __tabWidget)
{
__this->ensureWidgetVisible(__tabWidget);
}
});
}
else
Expand Down
10 changes: 6 additions & 4 deletions src/DockContainerWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class DockContainerWidgetPrivate
int VisibleDockAreaCount = -1;
CDockAreaWidget* TopLevelDockArea = nullptr;
QTimer DelayedAutoHideTimer;
CAutoHideTab* DelayedAutoHideTab;
QPointer<CAutoHideTab> DelayedAutoHideTab;
bool DelayedAutoHideShow = false;

/**
Expand Down Expand Up @@ -396,10 +396,12 @@ DockContainerWidgetPrivate::DockContainerWidgetPrivate(CDockContainerWidget* _pu
std::fill(std::begin(LastAddedAreaCache),std::end(LastAddedAreaCache), nullptr);
DelayedAutoHideTimer.setSingleShot(true);
DelayedAutoHideTimer.setInterval(500);
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.

if (DelayedAutoHideTab) {
auto GlobalPos = DelayedAutoHideTab->mapToGlobal(QPoint(0, 0));
qApp->sendEvent(DelayedAutoHideTab, new QMouseEvent(QEvent::MouseButtonPress,
QPoint(0, 0), GlobalPos, Qt::LeftButton, {Qt::LeftButton}, Qt::NoModifier));
}
});
}

Expand Down