Check item validity before using it
itemAt isn't guaranteed to always return an item, so check the validity of that first before trying to do things with it.
Differential Revision: https://phabricator.kde.org/D7467