mirror of
https://github.com/storytold/gridcraft.git
synced 2026-11-07 11:02:09 +00:00
`Workbook::next_object_id` returned one more than the largest id in use, saturating at `u32::MAX`. A workbook read from a file can carry an object with that id; every later insert (a chart, picture, shape, table or slicer) then got `u32::MAX` again, and so did each object of a copied sheet, whose ids also came from a saturating counter. Lookups and selection take the first object with an id, and `object.delete` removes every one. `Workbook::free_object_ids(count)` now returns distinct unused ids: those above the largest in use while they last, then the lowest free ones from 1. `next_object_id` takes the first of them, and the sheet copy takes one per copied object (and refuses if the id space were ever exhausted). The model test that recorded the saturation now checks the free ids instead, and a new one covers a file that used the largest ids: the free ids come from below, 100,000 of them distinct and in order. Test: object_ids_stay_unique_when_a_file_used_the_largest_id gives a shape id u32::MAX, inserts two shapes and copies the sheet; every shape id is distinct across both sheets. It fails without the fix (both new shapes get 4294967295).