mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 04:29:30 -10: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. (cherry picked from commit cbf1fd3e61710d9e8069ea1480b25734fd35d26f)
This commit is contained in:
1 parent
eab59d58df
commit
a11169e9a6
1 file changed
+9
-5
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user