fix for issue #44: Hang when going to preferences.

Fixed a bad for loop.