Skip to content

Dictionary::values(), Dictionary::keys() and Array::duplicate() create broken Arrays #470

Closed

Description

@DmitriySalnikov

c9a740b
Dictionary::values(), Dictionary::keys(), Array::duplicate() and maybe other functions create an Arrays that doesn't clear values properly

Dictionary values

Variant action_v = ProjectSettings::get_singleton()->get(String("input/ui_up"));
Dictionary action = action_v;
Array arr = action.values();

or

Variant action_v = ProjectSettings::get_singleton()->get(String("input/ui_up"));
Array arr = ((Dictionary)action_v).values();

or

((Dictionary)ProjectSettings::get_singleton()->get(String("input/ui_up"))).values();

result:

WARNING: ObjectDB::cleanup: ObjectDB instances leaked at exit (run with --verbose for details).
     At: core\object.cpp:2135
Leaked instance: InputEventJoypadButton:35 - Resource path:
Leaked instance: InputEventKey:34 - Resource path:
Hint: Leaked instances typically happen when nodes are removed from the scene tree (with `remove_child()`) but not freed (with `free()` or `queue_free()`).

keys

Dictionary d;
Ref<InputEventMouseButton> iemb(InputEventMouseButton::_new());
d[iemb] = iemb;
d.keys();
WARNING: ObjectDB::cleanup: ObjectDB instances leaked at exit (run with --verbose for details).
     At: core\object.cpp:2135
Leaked instance: InputEventMouseButton:1117 - Resource path:
Hint: Leaked instances typically happen when nodes are removed from the scene tree (with `remove_child()`) but not freed (with `free()` or `queue_free()`).

Array

Array a;
Ref<InputEventMouseMotion> iemb(InputEventMouseMotion::_new());
a.append(iemb);
a.duplicate();
a.clear();
WARNING: ObjectDB::cleanup: ObjectDB instances leaked at exit (run with --verbose for details).
     At: core\object.cpp:2135
Leaked instance: InputEventMouseMotion:1117 - Resource path:
Hint: Leaked instances typically happen when nodes are removed from the scene tree (with `remove_child()`) but not freed (with `free()` or `queue_free()`).

Also this works without leaks:

Array a;
Ref<InputEventMouseMotion> iemb(InputEventMouseMotion::_new());
a.append(a.duplicate());

With leaks:

a.append(((Dictionary)ProjectSettings::get_singleton()->get(String("input/ui_up"))).values());

🤯

Activity

  1. added
    bug
    on Nov 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions