Fix crash in custom dialog (reported by Sergey Gromov)