Skip to content

Commit fc1155d

Browse files
authored
Merge pull request #143 from endlessm/leak-fixes
Leak fixes
2 parents 9f6ab77 + 8988c0c commit fc1155d

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

addons/block_code/block_code_node/block_code.gd

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ class_name BlockCode
44
extends Node
55

66
@export var block_script: BlockScriptData = null
7-
static var plugin
87

98

109
func _ready():
@@ -31,10 +30,6 @@ func _enter_tree():
3130
new_bsd.generated_script = new_bsd.generated_script.replace("INHERIT_DEFAULT", new_bsd.script_inherits)
3231
block_script = new_bsd
3332

34-
if plugin == null:
35-
plugin = ClassDB.instantiate("EditorPlugin")
36-
plugin.add_inspector_plugin(load("res://addons/block_code/inspector_plugin/block_script_inspector.gd").new())
37-
3833

3934
func _update_parent_script():
4035
if Engine.is_editor_hint():

addons/block_code/block_code_plugin.gd

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ const MainPanel := preload("res://addons/block_code/ui/main_panel.tscn")
66
static var main_panel: MainPanel
77
static var block_code_button: Button
88

9+
const BlockInspectorPlugin := preload("res://addons/block_code/inspector_plugin/block_script_inspector.gd")
10+
var block_inspector_plugin: BlockInspectorPlugin
11+
912
var editor_inspector: EditorInspector
1013
var editor_selection: EditorSelection
1114

@@ -52,6 +55,8 @@ func _enter_tree():
5255
main_panel = MainPanel.instantiate()
5356
main_panel.undo_redo = get_undo_redo()
5457
block_code_button = add_control_to_bottom_panel(main_panel, _get_plugin_name())
58+
block_inspector_plugin = BlockInspectorPlugin.new()
59+
add_inspector_plugin(block_inspector_plugin)
5560

5661
# Remove unwanted class nodes from create node
5762
old_feature_profile = EditorInterface.get_current_feature_profile()
@@ -71,6 +76,8 @@ func _enter_tree():
7176

7277

7378
func _exit_tree():
79+
remove_inspector_plugin(block_inspector_plugin)
80+
7481
if block_code_button:
7582
remove_control_from_bottom_panel(main_panel)
7683
block_code_button = null
@@ -155,7 +162,8 @@ func select_block_code_node(block_code: BlockCode):
155162

156163

157164
func _refresh_block_code_node():
158-
main_panel.switch_block_code_node(_selected_block_code)
165+
if main_panel:
166+
main_panel.switch_block_code_node(_selected_block_code)
159167

160168

161169
func _on_selected_block_code_changed():

addons/block_code/inspector_plugin/block_script_inspector.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ func _parse_begin(object):
1010

1111
var button := Button.new()
1212
button.text = "Open Block Script"
13-
button.pressed.connect(func(): BlockCodePlugin.main_panel.switch_script(block_code))
13+
button.pressed.connect(func(): BlockCodePlugin.main_panel.switch_block_code_node(block_code))
1414

1515
var container := MarginContainer.new()
1616
container.add_theme_constant_override("margin_bottom", 10)

addons/block_code/ui/picker/categories/block_category.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class_name BlockCategory
2-
extends Object
2+
extends RefCounted
33

44
var name: String
55
var block_list: Array[Block]

0 commit comments

Comments
 (0)