Fix bug of saving the main window position