mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-21 09:49:21 +00:00
UI/Qt: Prevent division by zero in tab width calculation
On macOS, the first time TabBar::tabSizeHint is called, the count is reportedly zero, and results in a floating point exception on x64.
This commit is contained in:
parent
30b636e90b
commit
cbf1fd3e61
Notes:
github-actions[bot]
2024-08-30 19:09:10 +00:00
Author: https://github.com/trflynn89
Commit: cbf1fd3e61
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1233
1 changed files with 9 additions and 5 deletions
|
@ -24,12 +24,16 @@ TabBar::TabBar(QWidget* parent)
|
|||
|
||||
QSize TabBar::tabSizeHint(int index) const
|
||||
{
|
||||
auto width = this->width() / count();
|
||||
width = min(225, width);
|
||||
width = max(128, width);
|
||||
|
||||
auto hint = QTabBar::tabSizeHint(index);
|
||||
hint.setWidth(width);
|
||||
|
||||
if (auto count = this->count(); count > 0) {
|
||||
auto width = this->width() / count;
|
||||
width = min(225, width);
|
||||
width = max(128, width);
|
||||
|
||||
hint.setWidth(width);
|
||||
}
|
||||
|
||||
return hint;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue