Skip to content

Commit

Permalink
fix: 🐛 potential memory leak with script extensions (#522)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
KANAjetzt committed Jan 26, 2025
1 parent f5afc8c commit 8ae17b9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions addons/mod_loader/internal/script_extension.gd
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static func apply_extension(extension_path: String) -> Script:
ModLoaderLog.error("The child script path '%s' does not exist" % [extension_path], LOG_NAME)
return null

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

var parent_script: Script = child_script.get_base_script()
var parent_script_path: String = parent_script.resource_path
Expand Down

0 comments on commit 8ae17b9

Please sign in to comment.