fix a crash which occurs sometimes when setting the window title