I added checks for the setting's type before doing the static_cast.

I still don't think that it's necessary to add a NULL check for the GetDefinition(). If we manage to get into this code with a setting object that returns NULL for GetDefinition() something went very wrong during the initialization of the settings system.