rednblackgames / HyperLap2D

A powerful, platform-independent, visual editor for complex 2D worlds and scenes.
https://hyperlap2d.rednblack.games/
GNU General Public License v3.0
377 stars 67 forks source link

Crash when overlapping polygon #91

Open myyk opened 1 year ago

myyk commented 1 year ago

Describe the bug I was drawing a polygon that wrapped around itself and caused the app to crash.

To Reproduce I couldn't repro the bug.

Steps to reproduce the behavior:

  1. 'Create Primitive'
  2. Use 'Polygon Tool'
  3. Draw a doughnut like shape with around 20 vertices.
  4. Maybe it was random that it crashed when I had made the vertices overlap.
  5. Crash

Expected behavior No crash.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Polygon looked something like this before it crashed, with the "8"-vertex being moved over the point to the left of it: Screenshot from 2023-11-20 15-30-30

Stacktrace from crash

java.lang.NullPointerException: Cannot read the array length because "data" is null
        at games.rednblack.editor.controller.commands.component.UpdatePolygonVerticesCommand.cloneData(UpdatePolygonVerticesCommand.java:95)
        at games.rednblack.editor.controller.commands.component.UpdatePolygonVerticesCommand.payload(UpdatePolygonVerticesCommand.java:86)
        at games.rednblack.editor.view.stage.tools.PolygonTool.vertexUp(PolygonTool.java:149)
        at games.rednblack.editor.view.ui.followers.PolygonFollower$LineClickListener.touchUp(PolygonFollower.java:287)
        at com.badlogic.gdx.scenes.scene2d.InputListener.handle(InputListener.java:71)
        at com.badlogic.gdx.scenes.scene2d.Stage.touchUp(Stage.java:354)
        at com.badlogic.gdx.InputMultiplexer.touchUp(InputMultiplexer.java:124)
        at com.badlogic.gdx.InputEventQueue.drain(InputEventQueue.java:70)
        at com.badlogic.gdx.backends.lwjgl3.DefaultLwjgl3Input.update(DefaultLwjgl3Input.java:189)
        at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window.update(Lwjgl3Window.java:378)
        at com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationGLESFix.loop(Lwjgl3ApplicationGLESFix.java:192)
        at com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationGLESFix.<init>(Lwjgl3ApplicationGLESFix.java:166)
        at games.rednblack.editor.Main.main(Main.java:57)
fgnm commented 1 year ago

Really thanks for all the detailed reports :) In the last commit I probably catch up the NPE but not sure, I'll let this open if you experience other crashes

myyk commented 1 year ago

No problem, I'm glad they're helpful. I felt bad creating them but then realized I would appreciate them created for my projects.