Fix the bug which can crash the GUI.