Fix: crash when not even a single row fits for dropdowns on low resolution screens (#10934)

This commit is contained in:
Patric Stout 2023-06-04 17:07:18 +02:00 committed by GitHub
parent ee2d0745e9
commit c43a23cea8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 5 deletions

View File

@ -385,11 +385,8 @@ void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button
scroll = true;
uint avg_height = height / (uint)list.size();
/* Check at least there is space for one item. */
assert(available_height >= avg_height);
/* Fit the list. */
uint rows = available_height / avg_height;
/* Fit the list; create at least one row, even if there is no height available. */
uint rows = std::max<uint>(available_height / avg_height, 1);
height = rows * avg_height;
/* Add space for the scrollbar. */