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

EditorPlugin.remove_inspector_plugin() doesn't clean references, creating leaked instances at exit #55648

Closed
AnidemDex opened this issue Dec 5, 2021 · 0 comments · Fixed by #55658

Comments

@AnidemDex
Copy link

Godot version

v3.4.stable.official [206ba70]

System information

Windows 11 x64

Issue description

I was working in a integration of two different plugins, each one has different uses.

Making some experiments I discovered that, if you try to add more than 1 editor inspector plugin, at the moment you try to remove them, they'll not be removed from internal data of the inspector, causing leaked instances on exit.

ERROR: Condition "_first != nullptr" is true.
   at: ~List (./core/self_list.h:108)
ERROR: Condition "_first != nullptr" is true.
   at: ~List (./core/self_list.h:108)
WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
     at: cleanup (core/object.cpp:2064)
Leaked instance: GDScript:27266 - Resource path:
Leaked instance: GDScriptNativeClass:1107
Leaked instance: EditorInspectorPlugin:29377
Hint: Leaked instances typically happen when nodes are removed from the scene tree (with `remove_child()`) but not freed (with `free()` or `queue_free()`).
Orphan StringName: GDScriptNativeClass
Orphan StringName: EditorInspectorPlugin
Orphan StringName: _init
Orphan StringName: res://addons/textalog/plugin_script.gd
Orphan StringName: GDScript
StringName: 5 unclaimed string names at exit.

Relevant code on source:

void EditorInspector::remove_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) {

Steps to reproduce

Create a new plugin and use this code:

tool
extends EditorPlugin

class a extends EditorInspectorPlugin:
	pass

class b extends EditorInspectorPlugin:
	pass

var inspector_a = a.new()
var inspector_b = b.new()

func _enter_tree():
	add_inspector_plugin(inspector_a)
	add_inspector_plugin(inspector_b)

func _exit_tree():
	remove_inspector_plugin(inspector_a)
	remove_inspector_plugin(inspector_b)

The first inspector (inspector_a) will be removed without problems, but inspector_b will cause leaked instances when you close the editor.

Minimal reproduction project

No response

@Calinou Calinou added this to the 4.0 milestone Dec 5, 2021
@akien-mga akien-mga modified the milestones: 4.0, 3.5 Dec 6, 2021
AnidemDex added a commit to AnidemDex/Godot-DialogPlugin that referenced this issue Dec 6, 2021
While godotengine/godot#55648 is solved and
merged, I ended making all inspectors in a single file.

Is not a good idea, is hard to mantain, but that's what I do for now.
AnidemDex added a commit to AnidemDex/Godot-DialogPlugin that referenced this issue Dec 6, 2021
While godotengine/godot#55648 is solved and
merged, I ended making all inspectors in a single file.

Is not a good idea, is hard to mantain, but that's what I do for now.
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.

3 participants