Avoid potential segfaults if files are deleted.

Potentially, on a refresh, selection_ptr could be out of range
if files have been removed.