Fix application crash when rotating device with dialog open