Problem:
Resizing an SCollection throws a NullPointerException: this.bounds is null.
Investigation:
SCollection extends AbstractShape but its constructor calls super() without initializing the inherited bounds, leaving it null (src/main/java/ovh/gasser/newshapes/shapes/SCollection.java:21).
AbstractShape.resize() assumes bounds is non-null and dereferences it (src/main/java/ovh/gasser/newshapes/shapes/AbstractShape.java:47).
During mouse drag resize, Controller.handleMouseDragged() calls shape.resize(...), triggering the NPE (src/main/java/ovh/gasser/newshapes/ui/Controller.java:96).
SCollection derives its bounds dynamically from children (overrides getBounds()) instead of storing the inherited bounds field like other shapes.
Recommended minimal fix:
Prefer overriding resize() in SCollection so resizing operates on the collection by delegating/resizing children or recomputing bounds, avoiding reliance on the inherited bounds field.
As a secondary safeguard, consider adding a null guard in AbstractShape.resize() to avoid dereferencing bounds when it is null (fail-safe or throw informative exception).
Please implement the preferred approach: override resize() in SCollection to handle resizing correctly for collections, and add a small defensive null check in AbstractShape.resize() as a secondary safeguard if convenient.
Problem:
Resizing an SCollection throws a NullPointerException: this.bounds is null.
Investigation:
- SCollection extends AbstractShape but its constructor calls super() without initializing the inherited bounds, leaving it null (src/main/java/ovh/gasser/newshapes/shapes/SCollection.java:21).
- AbstractShape.resize() assumes bounds is non-null and dereferences it (src/main/java/ovh/gasser/newshapes/shapes/AbstractShape.java:47).
- During mouse drag resize, Controller.handleMouseDragged() calls shape.resize(...), triggering the NPE (src/main/java/ovh/gasser/newshapes/ui/Controller.java:96).
- SCollection derives its bounds dynamically from children (overrides getBounds()) instead of storing the inherited bounds field like other shapes.
Recommended minimal fix:
1. Prefer overriding resize() in SCollection so resizing operates on the collection by delegating/resizing children or recomputing bounds, avoiding reliance on the inherited bounds field.
2. As a secondary safeguard, consider adding a null guard in AbstractShape.resize() to avoid dereferencing bounds when it is null (fail-safe or throw informative exception).
Files referenced:
- src/main/java/ovh/gasser/newshapes/shapes/AbstractShape.java:47
- src/main/java/ovh/gasser/newshapes/shapes/SCollection.java:21
- src/main/java/ovh/gasser/newshapes/ui/Controller.java:96
Please implement the preferred approach: override resize() in SCollection to handle resizing correctly for collections, and add a small defensive null check in AbstractShape.resize() as a secondary safeguard if convenient.
Please:
1. Edit issue #31 with the corrected body.
2. Return confirmation and the final body used.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Problem:
Resizing an SCollection throws a NullPointerException: this.bounds is null.
Investigation:
Recommended minimal fix:
Files referenced:
Please implement the preferred approach: override resize() in SCollection to handle resizing correctly for collections, and add a small defensive null check in AbstractShape.resize() as a secondary safeguard if convenient.
Please: