Modified function such that the atom isn't used in the defaults.

This caused the routine to crash when the atom didn't have an icon or was null.
Tidy up and use more sane defaults.
Merge pull request #5868 from JimTheCactus/getFlatIcon_runtime

Fixes getFlatIcon Runtime on Atoms with no Icon