Skip to content

Polygon2D editor crash when undoing a "Sync Bones to Polygon" operation. #112203

@migueldeicaza

Description

@migueldeicaza

Tested versions

Godot 4.5, Godot 4.4

System information

MacOS

Issue description

The Polygon2DEditor class has a flaw, it sets the internal "node" value to the Polygon2D being edited which is called via the ::edit chain of methods.

Then tap undo, this will lead to a crash, as the method to undo the operation expects "node" to not be null, but there is nothing setting this value back to the proper node that it needs to operate on.

Not quite sure how to fix this, either introduce a new method purely on the plugin that sets the node during the undo/redo operation, or perhaps change _set_bones to not just take the bones argument, but also the Polygon2D upon which it will act, but the _set_bones method is in Polygon2D.cpp, so it does feel wrong to put it there.

Steps to reproduce

If you press the "Sync Bones to Polygon" in it, this will create an undo action. Then select a different object in the Scene - this will trigger the edit method to reset the value for node, and set it to null.

Minimal reproduction project (MRP)

crash-polygon.tar.gz

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Fix pending review

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions