fix crash in empty gallery