Fixed a crash when the orientation changes.