Repository: godot
Issue: Preloaded resources from `class_name` scripts break the editor's resource popup menu
Labels: bug,topic:editor

**Godot version:**
3.2.3


**OS/device including version:**
Ubuntu 16.04 64-bit


**Issue description:**
Any resources preloaded from a script with a `class_name` get loaded when building the resource popup menu (`EditorPropertyResource`'s menu), which notifies the inspector of a change and causes it to remove the popup. As a result, you're unable to create a new subresource:

See the video:

https://user-images.githubusercontent.com/165720/113481715-0d596d80-9493-11eb-9f39-3f45375a0051.mp4

**Steps to reproduce:**
1. Download the attached reproducer and open it in the editor.
2. Open resource_1.tres in the inspector **before** opening any other resource or script.
3. Try to click the button to add a subresource to either `Res 1` or `Res 2` properties.

If you instead open resource_2.tres first, the issue can't be demonstrated--the resource popup works. That might have something to do with the fact that resource_2.tres is the one preloaded from a script?

**Minimal reproduction project:**
[BrokenResourceMenuTest.zip](https://github.com/godotengine/godot/files/6252771/BrokenResourceMenuTest.zip)


The culprit looks like it must be something in this backtrace. Frames 25 & 26 are where EditorPropertyResource is trying to create the resource popup menu, and in frames 1 & 2, the inspector is notified of a change and nukes the menu.

```
#0  EditorInspector::_edit_request_change (this=0x97b0580, p_object=0x17197730, p_property=...) at editor/editor_inspector.cpp:1998
#1  0x00000000021cbee6 in EditorInspector::_changed_callback (this=0x97b0580, p_changed=0x17197730, p_prop=0x4c37b10 "") at editor/editor_inspector.cpp:2282
#2  0x00000000014c40b3 in Object::_change_notify (this=0x17197730, p_property=0x4c37b10 "") at ./core/object.h:588
#3  0x0000000003a2c0f3 in PlaceHolderScriptInstance::update (this=0x153f9ff0, p_properties=..., p_values=...) at core/script_language.cpp:587
#4  0x00000000014da52c in GDScript::_update_exports (this=0x17196db0, r_err=0x0, p_recursive_call=false) at modules/gdscript/gdscript.cpp:523
#5  0x00000000014d93c4 in GDScript::placeholder_instance_create (this=0x17196db0, p_this=0x10c24790) at modules/gdscript/gdscript.cpp:337
#6  0x00000000039df90c in Object::set_script (this=0x10c24790, p_script=...) at core/object.cpp:1033
#7  0x00000000039dc6eb in Object::set (this=0x10c24790, p_name=..., p_value=..., r_valid=0x0) at core/object.cpp:433
#8  0x00000000033dfe8e in ResourceInteractiveLoaderText::poll (this=0x171d86e0) at scene/resources/resource_format_text.cpp:603
#9  0x0000000003bfa4a9 in ResourceFormatLoader::load (this=0x66fe3c0, p_path=..., p_original_path=..., r_error=0x0) at core/io/resource_loader.cpp:197
#10 0x0000000003bfbeb4 in ResourceLoader::_load (p_path=..., p_original_path=..., p_type_hint=..., p_no_cache=false, r_error=0x0) at core/io/resource_loader.cpp:270
#11 0x0000000003bfcb1b in ResourceLoader::load (p_path=..., p_type_hint=..., p_no_cache=false, r_error=0x0) at core/io/resource_loader.cpp:402
#12 0x00000000015694b5 in GDScriptParser::_parse_expression (this=0x7fffffffb700, p_parent=0x10c15630, p_static=false, p_allow_assign=false, p_parsing_constant=false) at modules/gdscript/gdscript_parser.cpp:510
#13 0x000000000157388d in GDScriptParser::_parse_and_reduce_expression (this=0x7fffffffb700, p_parent=0x10c15630, p_static=false, p_reduce_const=false, p_allow_assign=false) at modules/gdscript/gdscript_parser.cpp:2026
#14 0x00000000015781e2 in GDScriptParser::_parse_block (this=0x7fffffffb700, p_block=0x10c15630, p_static=false) at modules/gdscript/gdscript_parser.cpp:2948
#15 0x000000000157f592 in GDScriptParser::_parse_class (this=0x7fffffffb700, p_class=0x10c15060) at modules/gdscript/gdscript_parser.cpp:4106
#16 0x00000000015a58bc in GDScriptParser::_parse (this=0x7fffffffb700, p_base_path=...) at modules/gdscript/gdscript_parser.cpp:8710
#17 0x00000000015a6046 in GDScriptParser::parse (this=0x7fffffffb700, p_code=..., p_base_path=..., p_just_validate=false, p_self_path=..., p_for_completion=false, r_safe_lines=0x0, p_dependencies_only=false)
    at modules/gdscript/gdscript_parser.cpp:8825
#18 0x00000000014dac3f in GDScript::reload (this=0x10c14890, p_keep_state=false) at modules/gdscript/gdscript.cpp:593
#19 0x00000000014e620c in ResourceFormatLoaderGDScript::load (this=0x6ca4970, p_path=..., p_original_path=..., r_error=0x0) at modules/gdscript/gdscript.cpp:2295
#20 0x0000000003bfbeb4 in ResourceLoader::_load (p_path=..., p_original_path=..., p_type_hint=..., p_no_cache=false, r_error=0x0) at core/io/resource_loader.cpp:270
#21 0x0000000003bfcb1b in ResourceLoader::load (p_path=..., p_type_hint=..., p_no_cache=false, r_error=0x0) at core/io/resource_loader.cpp:402
#22 0x000000000211e6f8 in EditorData::script_class_load_script (this=0x745b5e8, p_class=...) at editor/editor_data.cpp:927
#23 0x000000000211e347 in EditorData::script_class_get_base (this=0x745b5e8, p_class=...) at editor/editor_data.cpp:896
#24 0x000000000211dfab in EditorData::script_class_is_parent (this=0x745b5e8, p_class=..., p_inherits=...) at editor/editor_data.cpp:876
#25 0x0000000002288744 in EditorPropertyResource::_update_menu_items (this=0x171dac10) at editor/editor_properties.cpp:2433
#26 0x000000000228a546 in EditorPropertyResource::_update_menu (this=0x171dac10) at editor/editor_properties.cpp:2540
```