Fix SCollection resize NullPointerException #30
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.