1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

ComboTabBar: Ignore buttons that returns invalid element rect in dragOffset

Closes #2546
This commit is contained in:
David Rosca 2018-01-13 15:31:33 +01:00
parent b21e2634bc
commit cf5831d1db

View File

@ -1210,17 +1210,19 @@ bool TabBarHelper::event(QEvent* ev)
// Hack to get dragOffset from QTabBar internals
int TabBarHelper::dragOffset(QStyleOptionTab *option, int tabIndex) const
{
QStyle::SubElement element = QStyle::SE_TabBarTabLeftButton;
QRect rect;
QWidget *button = tabButton(tabIndex, QTabBar::LeftSide);
if (!button) {
element = QStyle::SE_TabBarTabRightButton;
button = tabButton(tabIndex, QTabBar::RightSide);
if (button) {
rect = style()->subElementRect(QStyle::SE_TabBarTabLeftButton, option, this);
}
if (!button) {
if (!rect.isValid()) {
button = tabButton(tabIndex, QTabBar::RightSide);
rect = style()->subElementRect(QStyle::SE_TabBarTabRightButton, option, this);
}
if (!button || !rect.isValid()) {
return 0;
}
const QPoint p = style()->subElementRect(element, option, this).topLeft();
return button->pos().x() - p.x();
return button->pos().x() - rect.topLeft().x();
}
// Taken from qtabbar.cpp