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

CONNECT_REFERENCE_COUNTED requires two disconnects for a single connect #44584

Closed
chess123mate opened this issue Dec 22, 2020 · 3 comments · Fixed by #47442
Closed

CONNECT_REFERENCE_COUNTED requires two disconnects for a single connect #44584

chess123mate opened this issue Dec 22, 2020 · 3 comments · Fixed by #47442

Comments

@chess123mate
Copy link

if (slot->reference_count >= 0) {

The simple fix is to change slot->reference_count >= 0 to slot->reference_count > 0, except then if the first connection does not use CONNECT_REFERENCE_COUNTED and then a second connection does (this does not currently error), then you would need only a single disconnect despite connect having been called two times.

@Calinou
Copy link
Member

Calinou commented Jan 2, 2021

@chess123mate Which Godot version did you experience this bug with?

Also, please upload a minimal reproduction project to make this easier to troubleshoot.

@chess123mate
Copy link
Author

Version: Godot Engine v3.2.3.stable.official

The project I was experimenting with when I discovered this bug (it is fairly minimal): Connect.zip

@Shatur
Copy link
Contributor

Shatur commented Mar 28, 2021

Can reproduce on 3.2.3 too:

extends Node2D


onready var _timer = $Timer


func _ready() -> void:
	_timer.connect("timeout", self, "_on_timeout", [], CONNECT_REFERENCE_COUNTED)
	_timer.connect("timeout", self, "_on_timeout", [], CONNECT_REFERENCE_COUNTED)
	_timer.connect("timeout", self, "_on_timeout", [], CONNECT_REFERENCE_COUNTED)
	_timer.disconnect("timeout", self, "_on_timeout")
	_timer.disconnect("timeout", self, "_on_timeout")
	_timer.disconnect("timeout", self, "_on_timeout")
#	_timer.disconnect("timeout", self, "_on_timeout") # Uncomment to prevent calling _on_timeout


func _on_timeout() -> void:
	print("Called!")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants