BUG:375325 Fix crash when saving group layers
The weak shared pointer allowed the image to be set to 0.