rednblackgames / HyperLap2D

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

Deleting a polygon, then using <CTRL>-Z to undo crashes the app #87

Closed trevordilley closed 1 year ago

trevordilley commented 1 year ago

Describe the bug When you create a polygon, add a few vertices, highlight a vertice, hit the delete key (thinking that would delete the vertex) it will delete the polygon. I assume that's correct behavior.

Then, using CTRL-Z to undo will result in a crash with a stack trace. Below is the stack trace:

HyperLap2D just crashed, stacktrace saved in: /Users/trevor/Library/Application Support/.hyperlap2d/crash/java-hyperlog.txt

 System: Mac OS X 13.5.2 (HyperLap2D v0.1.3-SNAPSHOT)

java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 129
    at com.artemis.utils.Bag.get(Bag.java:196)
    at com.artemis.ComponentMapper.get(ComponentMapper.java:65)
    at games.rednblack.editor.renderer.utils.ComponentRetriever.get(ComponentRetriever.java:167)
    at games.rednblack.editor.utils.runtime.SandboxComponentRetriever.get(SandboxComponentRetriever.java:12)
    at games.rednblack.editor.controller.commands.component.UpdatePolygonVerticesCommand.undoAction(UpdatePolygonVerticesCommand.java:61)
    at games.rednblack.editor.controller.commands.RevertibleCommand.callUndoAction(RevertibleCommand.java:51)
    at games.rednblack.editor.controller.commands.EntityModifyRevertibleCommand.callUndoAction(EntityModifyRevertibleCommand.java:45)
    at games.rednblack.editor.proxy.CommandManager.undoCommand(CommandManager.java:63)
    at games.rednblack.editor.view.stage.SandboxMediatorSandboxStageEventListener.keyDown(SandboxMediator.java:312)
    at games.rednblack.editor.view.stage.input.SandboxInputAdapter.keyDown(SandboxInputAdapter.java:46)
    at com.badlogic.gdx.InputMultiplexer.keyDown(InputMultiplexer.java:80)
    at com.badlogic.gdx.InputEventQueue.drain(InputEventQueue.java:58)
    at com.badlogic.gdx.backends.lwjgl3.DefaultLwjgl3Input.update(DefaultLwjgl3Input.java:189)
    at 

To Reproduce Steps to reproduce the behavior:

  1. Create a primitive polygon
  2. Add a point
  3. Press "Delete" key
  4. Press CTRL-Z to undo
  5. Observe the crash

Expected behavior The polygon that was deleted should reappear on the scene Screenshots

Screenshot 2023-10-23 at 8 39 39 PM

https://github.com/rednblackgames/HyperLap2D/assets/28691656/f594b4a2-8b9c-4199-8377-2435fd5b3066

Desktop (please complete the following information):