SteveDunn / Gleed2D

Generic Level Editor 2D
83 stars 28 forks source link

CustomProperty LinkedItem breaks after re-loading a level #34

Open AlexDiede opened 12 years ago

AlexDiede commented 12 years ago

Steps to recreate issue: 0) Create a level with two rectangle shapes in them (just use default names) 1) Add a custom property to 'Rectangle_1' of type 'Linked item' with any name 2) Choose 'Rectangle_2' for the value of the custom property you just created 3) Save the level 4) Restart Gleed2D 5) Load the level you just saved 6) Click on 'Rectangle_1' 7) Click on the dropdown box for the custom property (as if you were going to edit the value) 8) An error will pop up saying, "Unable to cast object of type 'System.String' to type 'Gleed2D.InGame.LinkedItem'."

If you save the level after doing these steps the custom property's value will be changed from 'Rectangle_2' to '$null$'.

I dug around in the code and tracked the cast that fails to line 24 of LinkedItemUiTypeEditor.cs in Gleed2D.Core.CustomUITypeEditors.

SteveDunn commented 12 years ago

Thanks for reporting the issue. I'll take a look and let you know.