jchambers/sort-by-log-size-plugin — pull request #1 by marquiswang (2012-01-23 04:03:33+00:00)
Title: Fixes for two bugs with Adium 1.4

The first two commits fix the two bugs:

1. Metacontacts cause the plugin to crash, preventing the contact list from loading at all.
* This was solved by using [listContact internalUniqueObjectID] for the cache key instead of [[listContact account] explicitFormattedUID], because metacontacts return a nil account on startup.
2. Metacontacts are cached with a log size of 0.
* The problem here was that Adium 1.4 initialized metacontacts before the accounts are connected, on the load of the contact list all of the metacontacts have no real subcontacts. Therefore, metacontacts have a log size of 0 that is cached and never removed. My solution was to disable caching for metacontacts completely. Instead, a metacontact looks up the cached value of each of its subcontacts each time. This works, but the only downside is that getContactLogSize is no longer static, and so the check to fall back on the uncached sort no longer works if for some reason the sort controller is of the wrong class. Personally, I think it is okay to remove this check since something really horrible has to happen if that were to happen.

Finally, the third commit is just a minor change to using removeObjectForKey when invalidating a cache object instead of setting it to nil.