export_tool_button self-referencing resources #15276
Closed
chrysopoeia
started this conversation in
Editor
Replies: 3 comments 2 replies
|
As mentioned on godotengine/godot#121729 we should document this and should consider adding a warning about it. Beyond that there is nothing we can and should do, since there are ways you could utilize this behaviour that are correct. |
0 replies
|
This behavior is documented:
You can use a getter instead: @export_tool_button("My Button", "Callable") var mybutton:
get: return func():
self.some_var = some_func()I also have a (closed) PR that allows you to create a shorthand. With it, you could do something like this (note the @export_tool_button("My Button", "Callable") var mybutton => func():
self.some_var = some_func() |
0 replies
|
Excellent answers, though I guess this is where the confusion on documentation comes in: tutorial |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
When adding an export tool button, the supplied lambda also gets added when running your project. This can cause a self-referencing issue where the resource will never be freed.
When closing your project you will see
ObjectDB instances were leaked at exitorresources still in use at exitexample:
work around this by setting those lambdas to null in the initializer:
This is an unknown to new users!
What do you think? Should the lambda only be available while in the editor?
All reactions