Godot errors/crashes after inspecting two different objects handled by the same plugin #73650
Description
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:
- "Edit Sprite": edits the last selected sprite
- "Edit Texture": edits the texture of the last selected sprite
This plugin handles BOTH Sprite2D
and Texture2D
.
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.
- Open the main scene and go to the 2D view
- Select the sprite
- In the bottom bar, click "Test plugin" to show the custom panel
- In the custom panel, click "Edit Texture" and "Edit Sprite" alternatively a bunch of times
- Go to Project Settings and turn off the plugin: Godot might crash already.
- If no crash occurred, click on the "Script" tab: observe crash.
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 that edit(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:
ERROR: Condition "plugins_list.has(p_plugin)" is true.
at: EditorPluginList::add_plugin (editor\editor_node.cpp:8119)
Which I dont understand either.
Activity