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

TabIcon: Avoid infinite loop when trying to change size from resize event

Instead call updateIcon delayed after setting tab button which achieves
resizing TabIcon to correct size too.

Fixes high cpu load from last commit.
This commit is contained in:
David Rosca 2018-03-25 09:09:58 +02:00
parent fcf274b768
commit ba3563362d
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
2 changed files with 3 additions and 10 deletions

View File

@ -147,8 +147,8 @@ void TabIcon::hide()
return;
}
emit resized();
setFixedSize(1, qMax(minimumHeight(), 16));
emit resized();
QWidget::hide();
}
@ -169,13 +169,6 @@ bool TabIcon::event(QEvent *event)
event->accept();
return true;
}
} else if (event->type() == QEvent::Resize) {
// Force resize to correct size
if (isVisible()) {
QTimer::singleShot(0, this, &TabIcon::show);
} else {
QTimer::singleShot(0, this, &TabIcon::hide);
}
}
return QWidget::event(event);

View File

@ -196,7 +196,7 @@ WebTab::WebTab(QWidget *parent)
// Workaround QTabBar not immediately noticing resizing of tab buttons
connect(m_tabIcon, &TabIcon::resized, this, [this]() {
if (m_tabBar) {
m_tabBar->setTabButton(tabIndex(), m_tabBar->iconButtonPosition(), m_tabIcon);
m_tabBar->update();
}
});
}
@ -346,7 +346,7 @@ void WebTab::attach(BrowserWindow* window)
m_locationBar->setBrowserWindow(m_window);
m_tabBar->setTabText(tabIndex(), title());
m_tabBar->setTabButton(tabIndex(), m_tabBar->iconButtonPosition(), m_tabIcon);
m_tabIcon->updateIcon();
QTimer::singleShot(0, m_tabIcon, &TabIcon::updateIcon);
auto currentChanged = [this](int index) {
const bool wasCurrent = m_isCurrentTab;