Commit: c9c332f42240f488ddb568041ba376ed37efd969 Author: Julian Eisel Date: Mon Feb 14 16:15:29 2022 +0100 Branches: asset-browser-grid-view https://developer.blender.org/rBc9c332f42240f488ddb568041ba376ed37efd969
Fix failed assert with small region size If there's not enough space to draw at least one item per row, there would be a failed assert in the code to skip drawing items scrolled out of view. =================================================================== M source/blender/editors/interface/grid_view.cc =================================================================== diff --git a/source/blender/editors/interface/grid_view.cc b/source/blender/editors/interface/grid_view.cc index 47b654ba583..85c3a32c10f 100644 --- a/source/blender/editors/interface/grid_view.cc +++ b/source/blender/editors/interface/grid_view.cc @@ -184,9 +184,10 @@ IndexRange BuildOnlyVisibleButtonsHelper::get_visible_range() const } const float view_height = BLI_rctf_size_y(&v2d_.cur); - const int count_rows_in_view = round_fl_to_int(view_height / style_.tile_height); + const int count_rows_in_view = std::max(round_fl_to_int(view_height / style_.tile_height), 1); max_items_in_view = (count_rows_in_view + 1) * cols_per_row_; + BLI_assert(max_items_in_view > 0); return IndexRange(first_idx_in_view, max_items_in_view); } @@ -285,7 +286,7 @@ void GridViewLayoutBuilder::build_from_view(const AbstractGridView &grid_view, uiLayout &layout = *uiLayoutColumn(current_layout(), false); const GridViewStyle &style = grid_view.get_style(); - const int cols_per_row = uiLayoutGetWidth(&layout) / style.tile_width; + const int cols_per_row = std::max(uiLayoutGetWidth(&layout) / style.tile_width, 1); BuildOnlyVisibleButtonsHelper build_visible_helper(v2d, grid_view, cols_per_row); _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs