AssetLoader icon indicating copy to clipboard operation
AssetLoader copied to clipboard

XmlConfigParser.parseVo bug using ASC2.0

Open ianmcgregor opened this issue 12 years ago • 2 comments

Hi Matan,

First off, thanks for creating such a great loading library :)

I started a new project today using ASC2.0 and found that AssetLoader is throwing errors due to invalid config values (in my case ConfigVO.type and ConfigVO.blendMode).

I've tracked it down to the XmlConfigParser.parseVo method. What is happening is that using the old compiler the XML attribute queries return null where the attribute does not exist, allowing the OR expression to select the value from the 'inheritFrom' VO. Using the new compiler, the attribute queries appear to be returning an empty XMLList. When assigned to the string properties in ConfigVO, you end up with empty strings for properties such as 'type', which breaks things later on.

child.type = xml.@type || inheritFrom.type;

So the above code will assign xml.@type even when it doesn't exist.

Now, I don't know whether to consider this a bug with ASC2.0 or AssetLoader, but I've found a couple of potential solutions I thought I'd run by you before submitting any pull request:

child.type = xml.hasOwnProperty("@type") ? xml.@type : inheritFrom.type;

child.type = xml.attribute("@type").length() > 0 ? xml.@type : inheritFrom.type;

I'm sure there are several other ways to approach it too. Shame to lose the simple OR assignment, I'm a bit fan of its simplicity, but I really want to start using ASC2.0 and AssetLoader!

Thanks for your time, Ian

ianmcgregor avatar Jan 30 '13 17:01 ianmcgregor

Hi Ian,

Thanks for pointing this out. I starting to use the ASC2.0 compiler as well and I will be fixing up Assetloader to support it sometime soon. As you may have noticed I promised v3 quite a while back, but due to workload, getting married, etc. I just didn't get round to it. I've got a half written version which I need to pick up on. But we should squeeze ASC2.0 compiler support in first. :)

Matan avatar Jan 31 '13 06:01 Matan

Hi, Good stuff! I'll carry on working this project with my patched version and I'll let you know if I find anything else. Congratulations BTW!

ianmcgregor avatar Jan 31 '13 10:01 ianmcgregor