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:
Timothy Flynn 2024-08-30 12:24:21 -04:00 committed by Tim Flynn
commit cbf1fd3e61
Notes: github-actions[bot] 2024-08-30 19:09:10 +00:00

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;
}