Skip to content

@export_tool_button breaks when changing the script contents (lambda hot-reloading) #97834

@caphindsight

Description

@caphindsight

Tested versions

  • Reproducible in 4.4dev3, the web editor

System information

I'm running MacOS, Firefox, web editor

Issue description

After adding a new @export_tool_button to a script, all tool buttons break. Seems to be fixable only by reloading the entire project.

Steps to reproduce

My script:

@tool
extends Node

@export_tool_button("Hello world")
var hello_world := func():
	print("Hello world")

The button appears in the UI. When I click it, the error message appears:

The value of property "hello_world" is Nil, but Callable was expected.

"Soft reload tool script" doesn't help.

After reloading the whole project though, it works as expected:

Hello world

But add another tool button, and both of them break again:

@tool
extends Node

@export_tool_button("Hello world")
var hello_world := func():
	print("Hello world")

@export_tool_button("Hello world2")
var hello_world2 := func():
	print("Hello world2")

Now the first one errors with

Tool button action "<invalid lambda>" is an invalid callable.

and the second one errors with

The value of property "hello_world2" is Nil, but Callable was expected.

Reloading the whole project again, again, fixes both problems.

Minimal reproduction project (MRP)

Sorry I couldn't figure out how to attach the web project, and I running out of time right now.
It's basically the default project with just one scene and one script, that I pasted above.
I'm confident this will show up in any project.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Fix pending review

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions