Fix a crash when change a material reclect cubemap

Replaces #1031