If you read Malcom Groves recent blog post and have XE3 or XE4 you might have taken a look at the FMX.Messages unit.

If you read Malcom Groves recent blog post and have XE3 or XE4 you might have taken a look at the FMX.Messages unit.

First I wondered what this has to do with FM - imho nothing. It should be part of the RTL as it clearly is platform/framework indipendent.

Then if you take a look at the code you most likely will find a bug - in the TMessage.Manager.Unsubscribe - comparing the address of two delegates will most likely NOT result true. At least someone noticed that and fixed it for XE4 - BUT ONLY for the overload which takes the procedure of object parameter, not for the procedure reference. Did I mention that it does not remove all listeners if you added one more than once?

Then obviously the person that wrote this don't know about TObjectDictionary that handles ownership of its values - no extra code in the destructor necessary - btw WHY THE F call FreeAndNil on a local variable (hence that cast to TObject because that needs to be passed to FreeAndNil)? Does anyone actually expect this to work with the iOS compiler and ARC? I don't.

Oh and speaking about destructor - you know we have class destructors these can destroy the lazy initialized FDefaultManager instance - no ugly finalization block needed that prevents the linker from removing the reference.

Comments

Post a Comment