Skip to content

Commit b155e84

Browse files
authored
fix: 🐛 potential memory leak with script extensions (#522)
fix: 🐛 fixed missing script parent path (#383) * feat: script extensions sorter checks load order (#357) * added a comparator method to sort extensions of the same script added a comparator method to sort extensions of the same script following the load order * added a table to avoid iterating through the load order every comparison * style edits/spacing changes renamed a var, added spacing to keep the style consistency * style: added an empty line * changed get_string_in_between to get_mod_dir * better description for get_mod_dir * fix: 🐛 fixed missing script parent path Before, if the same script was extended multiple times, the `parent_script_path` would be empty for all extensions except the first one. * fix: ✏️ removed no longer accurate comment
1 parent d100731 commit b155e84

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

addons/mod_loader/internal/script_extension.gd

+2-3
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static func apply_extension(extension_path: String) -> Script:
103103
ModLoaderLog.error("The child script path '%s' does not exist" % [extension_path], LOG_NAME)
104104
return null
105105

106-
var child_script: Script = ResourceLoader.load(extension_path)
106+
var child_script: Script = load(extension_path)
107107
# Adding metadata that contains the extension script path
108108
# We cannot get that path in any other way
109109
# Passing the child_script as is would return the base script path
@@ -116,8 +116,7 @@ static func apply_extension(extension_path: String) -> Script:
116116
# class multiple times.
117117
# This is also needed to make Godot instantiate the extended class
118118
# when creating singletons.
119-
# The actual instance is thrown away.
120-
child_script.new()
119+
child_script.reload()
121120

122121
var parent_script: Script = child_script.get_base_script()
123122
var parent_script_path: String = parent_script.resource_path

0 commit comments

Comments
 (0)