fix crash when going back from gallery