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

Fixed Memory Leaks in CharacterSelect.gd #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions ui/CSS/CharacterSelect.gd
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ func _ready():
var pi_scene = load("res://characters/PlayerInfo.tscn").instance()
ModLoader.saveScene(pi_scene, "res://ui/PlayerInfo.tscn")

# TriMay) Nodes are not ref-counted
# by default, nodes are cleaned up when their parents are
# instances not placed in scene tree must be cleaned up manually
# ALSO, as far as I can tell, ModLoader.saveScene packs the scene into a PackedScene, which I don't believe needs the original nodes to exist anywhere
pi_scene.queue_free()

#get headers
var h = File.new()
h.open("res://cl_port/headers/sample.header", File.READ)
Expand Down Expand Up @@ -622,6 +628,13 @@ func loadListChar(index, hideName = false): # hide name parameter is for online,

ModLoader.saveScene(char_scene, _charPath)

# TriMay) Nodes are not ref-counted
# by default, nodes are cleaned up when their parents are
# instances not placed in scene tree must be cleaned up manually
# ALSO, as far as I can tell, ModLoader.saveScene packs the scene into a PackedScene, which I don't believe needs the original nodes to exist anywhere
if miss == []:
char_scene.queue_free()

# update the button's character scene
bttContainer.get_node(curFighter).character_scene = load(_charPath)

Expand Down Expand Up @@ -1078,6 +1091,12 @@ func _importHolderPortrait(folder, scenePath, charName):
sc.name = "Error\ncharacter scene must be unedited"
ModLoader.saveScene(sc, scenePath)

# TriMay) Nodes are not ref-counted
# by default, nodes are cleaned up when their parents are
# instances not placed in scene tree must be cleaned up manually
# ALSO, as far as I can tell, ModLoader.saveScene packs the scene into a PackedScene, which I don't believe needs the original nodes to exist anywhere
sc.queue_free()

return scenePath
break

Expand Down