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:
Timothy Flynn authored and Nico Weber committed 2025-10-29 12:55:26 -07:00
1 parent eab59d58df
commit a11169e9a6
1 file changed
+9 -5
+9 -5
View File
@@ -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;
}