Skip to content
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

Computeds persist after their scenes are destroyed and error when they try to update #5

Open
jdtjenkins opened this issue Sep 18, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@jdtjenkins
Copy link

Hi, just reporting a bug, not sure if I can fix it in userland or not!

When you create a computed in a scene, then change scene or otherwise that scene then gets freed - any computed (and I assume effects, though I haven't tested that) persist, so when they try and update again they error. So we need some way to remove computeds from the graph or something I think.

I have included an example project which reproduces the error and included some instructions in the main scene.
test-rdot-computed.zip

Thank you for creating this, coming to Godot from JS here and Rdot is amazing

@jdtjenkins
Copy link
Author

So we need some way to remove computeds from the graph or something I think.

So this actually seems to work perfectly... If you have a computed, then remove it from the graph on scene tree exit

extends Node2D

@onready var thingLabel: Label = $ThingLabel

var thingComputed = R.computed(func(_ignore):
	return "Thing Doubled:" + str(Global.thingDoubled.value)
)

func _ready():
	R.bind(thingLabel, "text", thingComputed)

func _exit_tree() -> void:
	var graph = RdotGraph.getInstance()
	
	graph.consumerDestroy(thingComputed.node)

So this is using the RdotGraph internal, and I think this works? Wonder if it's worth having a less "internal-y" way of doing this?

@Nitwel Nitwel self-assigned this Sep 18, 2024
@Nitwel Nitwel added the bug Something isn't working label Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants