Repository: godotengine/godot (language: cpp)

Issue:
Derived of ViewportTexture class becomes ViewportTexture in Sprite2D after NodePath selected
### Tested versions

4.4

### System information

Linux, x86_64

### Issue description

If you create class like:
```gdscript
extends ViewportTexture
class_name ViewportTexture2
```

Then try to select `ViewportTexture2` in Sprite2D `texture`, after selecting NodePath in opened window, `texture` class in Sprite2D becomes `ViewportTexture`

Only way is to click Cancel in window  with selecting NodePath and then click on Assign:

![Image](https://github.com/user-attachments/assets/a8e0b174-a6ff-42f9-ba30-0f5bd3f7a512)


### Steps to reproduce

Create class derived from `ViewportTexture`
Try to select it for Sprite2D `texture`

### Minimal reproduction project (MRP)

[mrp_viewporttexture.zip](https://github.com/user-attachments/files/19103401/mrp_viewporttexture.zip)


Discussion / hints:

Fix patch:
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 935915a0c080..3a813c091e38 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -3228,8 +3228,9 @@ void EditorPropertyResource::_viewport_selected(const NodePath &p_path) {
 		return;
 	}
 
-	Ref<ViewportTexture> vt;
-	vt.instantiate();
+	Ref<ViewportTexture> vt = get_edited_property_value();
+	ERR_FAIL_COND(vt.is_null());
+
 	vt->set_viewport_path_in_scene(get_tree()->get_edited_scene_root()->get_path_to(to_node));
 
 	emit_changed(get_edited_property(), vt);


Test patch: