bug: SText.updateMeasuredBounds() mutates a defensive copy instead of internal state #27

Closed
opened 2026-03-27 16:19:49 +00:00 by thib8956 · 0 comments
Owner

In SText.updateMeasuredBounds(), the call getBounds().setSize(...) mutates a copy of the bounds rectangle (since getBounds() returns a defensive copy) and discards the result. This means resized dimensions are silently lost.

Impact: Cloning an SText that has been resized will produce a clone with default dimensions instead of the resized ones.

Found during: Review of PR #15 (ShapeContractTest). The contract test passes only because the factory creates SText with default bounds.

Expected fix: updateMeasuredBounds() should mutate the internal bounds field directly rather than calling getBounds().

In `SText.updateMeasuredBounds()`, the call `getBounds().setSize(...)` mutates a **copy** of the bounds rectangle (since `getBounds()` returns a defensive copy) and discards the result. This means resized dimensions are silently lost. **Impact:** Cloning an `SText` that has been resized will produce a clone with default dimensions instead of the resized ones. **Found during:** Review of PR #15 (ShapeContractTest). The contract test passes only because the factory creates `SText` with default bounds. **Expected fix:** `updateMeasuredBounds()` should mutate the internal `bounds` field directly rather than calling `getBounds()`.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: thib8956/new-shapes#27