Fixed a crash when changing the orientation after bringing the application back to the foreground.