Fix SCollection resize NullPointerException #30

Closed
opened 2026-03-27 17:46:29 +00:00 by thib8956 · 0 comments
Owner

Resizing an SCollection throws a NullPointerException in the AWT event thread.\n\nSteps to reproduce:\n1. Create or select an SCollection\n2. Start dragging one of its resize handles\n\nExpected:\n- The collection resizes normally\n\nActual:\n- The application crashes with:\n java.lang.NullPointerException: Cannot read field "y" because "this.bounds" is null\n at ovh.gasser.newshapes.shapes.AbstractShape.resize(AbstractShape.java:47)\n at ovh.gasser.newshapes.ui.Controller.handleMouseDragged(Controller.java:96)\n\nRoot cause:\n- SCollection extends AbstractShape but its constructor leaves the inherited bounds field null\n- AbstractShape.resize() assumes bounds is initialized and accesses bounds.y directly\n- Other shapes initialize bounds, but SCollection appears to compute its bounds dynamically from children and never populates the base field\n\nRelevant files:\n- src/main/java/ovh/gasser/newshapes/shapes/AbstractShape.java:47\n- src/main/java/ovh/gasser/newshapes/shapes/SCollection.java:21\n- src/main/java/ovh/gasser/newshapes/ui/Controller.java:96\n\nSuggested fix:\n- Override resize() in SCollection so it does not rely on the inherited bounds field, or otherwise ensure bounds is initialized before AbstractShape.resize() is used.

Resizing an SCollection throws a NullPointerException in the AWT event thread.\n\nSteps to reproduce:\n1. Create or select an SCollection\n2. Start dragging one of its resize handles\n\nExpected:\n- The collection resizes normally\n\nActual:\n- The application crashes with:\n java.lang.NullPointerException: Cannot read field "y" because "this.bounds" is null\n at ovh.gasser.newshapes.shapes.AbstractShape.resize(AbstractShape.java:47)\n at ovh.gasser.newshapes.ui.Controller.handleMouseDragged(Controller.java:96)\n\nRoot cause:\n- SCollection extends AbstractShape but its constructor leaves the inherited bounds field null\n- AbstractShape.resize() assumes bounds is initialized and accesses bounds.y directly\n- Other shapes initialize bounds, but SCollection appears to compute its bounds dynamically from children and never populates the base field\n\nRelevant files:\n- src/main/java/ovh/gasser/newshapes/shapes/AbstractShape.java:47\n- src/main/java/ovh/gasser/newshapes/shapes/SCollection.java:21\n- src/main/java/ovh/gasser/newshapes/ui/Controller.java:96\n\nSuggested fix:\n- Override resize() in SCollection so it does not rely on the inherited bounds field, or otherwise ensure bounds is initialized before AbstractShape.resize() is used.
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#30