fixed possible null pointer error

Change-Id: I1544eb6334fa9139f3f6abb33c90b0a41fcbc8b7
added workaround for "set selectedItems" not working with
selectedItemsCompareFunction

Change-Id: Ibdf72733702211fca0508959d189e5fe8b4c5a85