-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Godot errors/crashes after inspecting two different objects handled by the same plugin #73650
Comments
|
Yet another note after seeing this suggestion #40166 (comment):
Then my plugin's UI gets closed, as I searched how the VisualShaderEditorPlugin handles editing sub-resources inside nodes with the inspector, without getting bothered, and it uses |
I got a similar bug today, the engine sunddely crashes when I click on the TileMap node. =/
|
I am also getting In my case, the error is not associated with crashes or any other obvious problems. |
Never mind! A new project with no plugins still prints this error when opening the TileSet editor, so it's coming from the engine itself.
|
I'm seeing the same error after doing tile set/map for a moment. Using Godot v4.0.stable.official [92bee43]. No plugins added to the project. |
For the record I still see this kind of errors in the editor once in a while. #74717 seems related. |
Godot 4.1.1. No plugins, worked with TileMaps for a day learning the engine. This is all that shows up when starting up my project:
|
^ This is fixed in 4.2. |
No longer crashes on master. I guess the issue is resolved? |
Closing per the comment above. Please let me know if the issue is still reproduceable for you in 4.2. We'll probably need an updated MRP if it is. |
Sorry but this is not the same:
It's ONE plugin handling two TYPES of objects. But I guess if you also include the editor's core plugins, that also makes two plugins handling the same classes (which prevents any extensibility/custom sprites??) But I guess it's also documented as not being supported. But there is no explanation about how else it should be done... this is quite a severe limitation. I've been using that for several reasons:
I'm still working on 4.1.3 where the error still prints, although I havent experienced crashes in my plugins (therefore I focused my limited time on more important things). Will eventually start testing 4.2, but regardless, handling the limitation is unclear at the moment. |
You can manually determine edited object by using |
Unfortunately, |
It's emitted only for the main inspector object.
IIRC there is a proposal for more plugins per addon. It shouldn't be difficult to implement. That's how TileMap issues were fixed. There is 2 separate handler plugins now, dependent on each other to make sure you can edit both without problems.
The editor has a few editing contexts - the scene tree, inspector and sub-inspectors. They can operate independently, i.e. call
Hmm, maybe I could look into your plugin to see how things are implemented and give some advice. |
My GDScript plugin isn't directly affected because it only handles nodes, however I have the issue in my voxel terrain module, which nests resources inside nodes at multiple levels. If you want to have a look (although there is a lot going on): For context, here is a screenshot showing one example of nesting: Here showing the case of two of the plugins in my module: I rely on And this in There is of course more to it, notably the fact Note: I'm intentionally not using any API that isn't available to GDExtensions. There are tricks the core editor does I can't rely on. |
I did a quick patch with 2 changes:
The code is hacky, but you get the idea. With this fix I am able to see the Terrain button and graph editor at the same time without errors, so I think it works. I don't know the plugin enough to test it properly. |
Had a look at the patch, it really looks like a hack. Seeing stuff like this in those functions makes things confusing compared to what they are meant for. Notably I feel like Godot should have cleaner ways to code things for contextes like this. It constantly happens for me and it's tiring to keep adding hacks because it feels like I'm loosing control and could break some random day. But not sure what would have to change... as I described earlier, the logic seems too restrictive, partially ill-formed or unclear (both in docs and error messages). Because even though the API could still assume only one "thing" is edited at a time, in practice it doesn't always exist alone in a void, and may be nested in related resources, nodes or objects, which may be part of a whole context with interacting UIs. The sole fact you can have a node selected in the scene tree and a different object edited in the inspector is an example of this, but it goes beyond that of course. I gave your patch a try, and seems to work when I select a graph resource in a terrain. Actually, that second case I just described is indirectly triggered by my own code, which simply needs to use the inspector to edit a specific "sub-object" of my graph resource, while keeping the graph editing context: get_editor_interface()->inspect_object(*wrapper); Therefore, there might be a simpler solution than your hack here.
Which sounds like it would solve this specific case, and I would be able to remove this sub-object class from _ignore_edit_null = true;
_ignore_make_visible = true;
get_editor_interface()->inspect_object(*wrapper, String(), true);
_ignore_edit_null = false;
_ignore_make_visible = false; Which luckily seems to be working because neither |
…ype. This was causing multiple plugins to handle the same object, which Godot is not expecting by design. (godotengine/godot#73650 (comment)) It is still quite a hole in the API, because nested editing contextes are happening very often in this project, and need to be handled somehow. Errors are also really obscure as they lack the details that would help figuring out these problems. VoxelTerrainEditorPlugin was handling all these types just to avoid edit(null) and make_visible(false) which would make its tools disappear when selecting anything else, which is not desired when the object is actually part of the terrain's configuration (modifiers, generators...). Turns out, removing this kept behavior decent enough. For some reason inspecting the generator didn't make terrain controls disappear. However, they might disappear with modifiers now, but we'll see later if we need to bring back some workaround for them.
Can you check if this patch fixes your issue with The limitation of one object per plugin/context can't be lifted, because it makes the editor more predictable when unediting objects. However, assuming my above patch is working (not tested), we could have something like |
FYI, these are all the changes I went with for working around the errors so far: Zylann/godot_voxel@f86ab5c I noticed that completely removing the "side handling" for the terrain editor plugin actually didn't have harmful effects [anymore?] (at least in use cases I tested). I was quite curious because I thought selecting a sub-inspector would cause I tested your patch: |
This is likely result of the editing context split, which happened in some 4.0 alpha IIRC. Scene tree and editor properties are separate editing contexts.
I'd have to look into it, but the module doesn't compile on master. |
Should be fixed now |
I tested the graph in the newest version. Clicking a graph node will open it in the inspector, with no error printed. Not sure what's the problem. The Terrain button in the toolbar is still visible, but VoxelTerrain is not in the inspector, because it's taken by graph node. That looks like expected behavior. |
Forgot to mention: that's because there is still a workaround to prevent the issue from being noticed.
That's expected. |
When you click GraphNode, it will be edited in the inspector. Any plugin that uses inspector will lose its editing context and receive |
Is it adressing both calls to |
These two methods are called together. At least in the case that affects your plugin. |
…ype. This was causing multiple plugins to handle the same object, which Godot is not expecting by design. (godotengine/godot#73650 (comment)) It is still quite a hole in the API, because nested editing contextes are happening very often in this project, and need to be handled somehow. Errors are also really obscure as they lack the details that would help figuring out these problems. VoxelTerrainEditorPlugin was handling all these types just to avoid edit(null) and make_visible(false) which would make its tools disappear when selecting anything else, which is not desired when the object is actually part of the terrain's configuration (modifiers, generators...). Turns out, removing this kept behavior decent enough. For some reason inspecting the generator didn't make terrain controls disappear. However, they might disappear with modifiers now, but we'll see later if we need to bring back some workaround for them.
@Zylann mentioned this error occurs when handling the same object by two different plugins, but I have the exact same error when handling subresources with just one plugin. In my plugin I override
But whenever I select a subresource in the inspector, I get:
What's more, the subresource closes in the inspector, preventing me to edit it any further. |
Well that error appears when you try to edit multiple objects by the same plugin within the same editor context, which is very likely to happen when your plugin handles any resource. |
Godot version
Godot 4 rc2
System information
Windows 10 64 bits NVIDIA GeForce GTX 1060
Issue description
I was trying to reproduce a nasty error I started having since stuff got changed in some areas of editor plugins, but in RC2 instead of reproducing my issue, I ended up finding this crash. So I thought I'd report it...
I wrote a simple test plugin that adds a bottom panel with two buttons:
This plugin handles BOTH
Sprite2D
andTexture2D
.Steps to reproduce
After testing the plugin a bit, I turned it off, then clicked on the
Script
tab: Godot crashes. No information popup or logs, just shuts down.Minimal reproduction project
EditorPluginEditAnotherHandled.zip
This project has the plugin enabled by default.
Secondary note:
I was told that one of the changes to EditorPlugin was that
_edit(null)
can be called when "there is no longer any selected object handled by this plugin" (seen in the doc). But if you look in the console while alternating the two buttons (which ask the editor to inspect two different objects handled by the plugin), you will notice thatedit(null)
occurs half of the time, I dont understand why.Third note:
When testing this repro in master 9c960a8, if I select the sprite and then click on the "Edit Texture" button, I get an error:
Which I dont understand either.
The text was updated successfully, but these errors were encountered: