2009
08.04

I guess you can call this an unofficial part 4 of my 3 part “Bug hunting in the Flex SDK” series (1,2,3). Like a lot of patches, my SDK-19385 (ObjectUtils.compare() thinks that if A=B and C=D, A = C) (SDK-22491) was rejected. I’m not going to just let that hang out there like a lot of community patch attempts so it’s time for another round. Fortunately, Ryan Frishburg left a nice comment.

Let’s not do String comparisons…that’s too slow. Let’s build up a better dictionary mapping equal objects to equal objects (or equal to unequal ones). That would be the correct fix here.

Which is also a point I mentioned when I submitted the patch. There is another way to fix the bug, but rather than the laser surgery, I have to go in with a scalpel. This time I’m altering a few function’s arguments. All the functions are private, but it’s something I’d rather avoid.

I tried mirroring the functionality of the string function I used, but without having to deal with strings. What made this work so well was the resetting of object ids every time you built the string. That’s not an option here because we don’t want to lose the generic object IDs.

My original thought of a fix was to pass a list of objects that are parents of the object is probably the best option. I finally defaulted back to this, but ran into another problem with Flex. You cannot pass by reference. I tried the ObjectUtil.copy() function, but it doesn’t work with dictionaries (SDK-13787). That meant I had to perform the copy within the compare function. It’s not perfect, but when dealing with infinite recursion not much is. I looked into altering the copy function, but I didn’t see a way to determine if a dictionary was using weak references.

The new patch is at SDK-22552

Related Posts (generated):

No Comment.

Add Your Comment

 

Switch to our mobile site