godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.28k stars 21.04k forks source link

InspectorPlugin.can_handle(arg) can receive objects which are not exposed to GdScript #36078

Open kubecz3k opened 4 years ago

kubecz3k commented 4 years ago

Godot version: 40d1b0bfdb62d24d72f1f0102a7caf6f1c14e595

OS/device including version: Ubuntu 18.04 64bit

Issue description: When we create InspectorPlugin and we implement can_handle(arg_obj) function, I would expect the argument will be an Object (like its mentioned in docs). But it seems it's not always a case, in my particular case it was an instance of SectionedInspectorFilter (class which is not exposed to GdScript in the first place). I'm not 100% sure but I think this is an undesired behavior.

This makes such implementations of can_handle() improper:

func can_handle(in_object):
    return "some_property" in in_object

If we will use that concrete implementation, then when navigating inside of Editor Settings, we will experience a flood of such warnings: core/project_settings.cpp:209 - Property not found: application/config/some_property

inspector_plugin_can_handle

Steps to reproduce: Short way:

  1. Download reproduction project
  2. Open Editor settings, notice there is a flood of core/project_settings.cpp:209 - Property not found: application/config/some_property warnings in the editor output
  3. It can be fixed/worked around by correcting res://addons/com.plugin.issue/InspectorPlugin.gd can_handle(arg) implementation

Long way (general steps):

  1. Create new Plugin and inspector plugin.
  2. Inside InspectorPlugin implement can_handle method:
    func can_handle(in_object):
    return "some_property" in in_object
  3. Register inspector plugin inside the Plugin
  4. Open Editor settings and take a look at console output, there should be a lot of core/project_settings.cpp:209 - Property not found: application/config/some_property errors

Minimal reproduction project: inspector_plugin_can_handle_issue.zip

KoBeWi commented 3 years ago

Well, SectionedInspectorFilter IS an Object. The fact that it's not exposed only means that there's no documentation for it and likely methods are not bound, so you can't call them from GDScript.

The actual issue is that these objects shouldn't be sent to the plugin. Looks like Project Settings use the same control as Scene Tree Dock, so the plugin just receives anything that is clicked.

btw valid in 3.2.4 beta4

me2beats commented 3 years ago

if I have an InspectorPlugin and open EditorSettings, I can see SectionedInspectorFilter ImportDockParameters ScriptEditorDebuggerVariables etc "handled" in parse_begin for example. How can I disable handling them? I only need to work with objects which can be used in a game

DaelonSuzuka commented 2 years ago

I'm still having this problem with an InspectorPlugin and SectionedInspectorFilter objects in 3.4.2.