### Godot version

Godot 4.0 beta 14

### System information

Debian 11, X11 Nvidia proprietary driver, GLES3 Compatibility

### Issue description

When creating a new scene and add a Sprite2D node, the node image becomes corrupted when selecting the root node.
The problem is gone after saving & re-opening the editor.

![Screenshot from 2023-01-24 12-19-24](https://user-images.githubusercontent.com/94308700/214218462-979ed804-6128-4fbb-87d3-286de9db9e7f.png)

Selecting the root node:
![Screenshot from 2023-01-24 12-19-35](https://user-images.githubusercontent.com/94308700/214218528-944083f4-f5fc-4088-a6c8-7702215ce1a0.png)

The resource preview is wrong too.
![Screenshot from 2023-01-24 12-19-48](https://user-images.githubusercontent.com/94308700/214218557-34177eba-98cc-46aa-86f3-9f613899137a.png)


### Steps to reproduce

Pretty straightforward.

### Minimal reproduction project

Any sprite will do, i think.
(0, 0, 1.0, 1.0));
	glReadPixels(0, 0, texture->alloc_width, texture->alloc_height, GL_RGBA, GL_UNSIGNED_BYTE, &w[0]);
	glBindFramebuffer(GL_FRAMEBUFFER, 0);
	glDeleteTextures(1, &temp_color_texture);
	glDeleteFramebuffers(1, &temp_framebuffer);
	data.resize(data_size);
	ERR_FAIL_COND_V(data.size() == 0, Ref<Image>());
	Ref<Image> image = Image::create_from_data(texture->width, texture->height, false, Image::FORMAT_RGBA8, data);
	ERR_FAIL_COND_V(image->is_empty(), Ref<Image>());
	if (texture->format != Image::FORMAT_RGBA8) {
		image->convert(texture->format);
	}
	if (texture->mipmaps > 1) {
		image->generate_mipmaps();
	}
#endif
#ifdef TOOLS_ENABLED
	if (Engine::get_singleton()->is_editor_hint() && !texture->is_render_target) {
		texture->image_cache_2d = image;
	}
#endif
	return image;
}
void TextureStorage::texture_replace(RID p_texture, RID p_by_texture) {
	Texture *tex_to = texture_owner.get_or_null(p_texture);
	ERR_FAIL_COND(!tex_to);
	ERR_FAIL_COND(tex_to->is_proxy); 
	Texture *tex_from = texture_owner.get_or_null(p_by_texture);
	ERR_FAIL_COND(!tex_from);
	ERR_FAIL_COND(tex_from->is_proxy); 
	if (tex_to == tex_from) {
		return;
	}
	if (tex_to->canvas_texture) {
		memdelete(tex_to->canvas_texture);
		tex_to->canvas_texture = nullptr;
	}
	if (tex_to->tex_id) {
		glDeleteTextures(1, &tex_to->tex_id);
		tex_to->tex_id = 0;
	}
	Vector<RID> proxies_to_update = tex_to->proxies;
	Vector<RID> proxies_to_redirect = tex_from->proxies;
	tex_to->copy_from(*tex_from);
	tex_to->proxies = proxies_to_update; 
	if (tex_to->canvas_texture) {
		tex_to->canvas_texture->diffuse = p_texture; 
	}
	for (int i = 0; i < proxies_to_update.size(); i++) {
		texture_proxy_update(proxies_to_update[i], p_texture);
	}
	for (int i = 0; i < proxies_to_redirect.size(); i++) {
		texture_proxy_update(proxies_to_redirect[i], p_texture);
	}
	
	texture_owner.free(p_by_texture);
	texture_atlas_mark_dirty_on_texture(p_texture);
}
void TextureStorage::texture_set_size_override(RID p_texture, int p_width,