Fixes #80958: we check if the layer was previously added before readding it.