Skip to content

Conversation

@Quillraven
Copy link
Contributor

@Quillraven Quillraven commented Oct 31, 2025

fix for #7717.

@BoBIsHere86 please play around with it as well whenever you have time.

The problem was with nested classes. My example was assigning a "project class" that has a class property itself to a tile but not specifying any of the values of the class property.

We then got an empty Json object in loadMapPropertiesClassDefaults and the classMember.defaultValue.asString() then failed.

The comment that class properties were already loaded before was wrong. It is true for flat class properties but it is not the case for nested classes (or at least not in that specific scenario).

We now handle this case with the "class".equals(classMember.type) branch. I also enhanced the test and tried it in GWT and worked on my machine. I was also able to reproduce the issue of my project with this test initially.

The new test object looks like this (Class is assigned to a project class called "testClassNested" which has another class property called "classClass"):
image

I also played around with it some more by adding more nesting and overriding certain values on different levels. For me it looked fine but would be great if someone else also plays around a little bit with it.


Iirc this method and the problem was introduced by me. Sorry for that! :(

tommyettinger
tommyettinger previously approved these changes Oct 31, 2025
Copy link
Member

@tommyettinger tommyettinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change seems good. Test looks solid. Are we sure that the old case, where the property was actually a String, still works here in case old maps actually relied on that?

@Quillraven
Copy link
Contributor Author

Good input. I think it should work because the type should be string instead of class but I will add another object to the properties test map to validate it and to not break it in the future ;)

@BoBIsHere86
Copy link
Contributor

I should have some free time this weekend. I'll give this a quick once over and a test, then report back any findings.

Copy link
Member

@tommyettinger tommyettinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the extra test! Approved again.

@BoBIsHere86
Copy link
Contributor

Had a moment to finally take a look. This seems pretty solid, as well as the tests.
The fix was pretty isolated to the newer class related features. So I wasn't too worried about this messing with anything else. I did a double check and went through all the tiled tests locally, just incase. All ran as predicted.
I think this is a nice clean fix. 👍

@obigu obigu added this to the 1.14.1 milestone Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants