Merge pull request #38507 from RandomShaper/fix_cleanup_info_3.2
Fix potential crash when listing leaked objects (3.2)
This commit is contained in:
commit
1df2e81d3e
|
@ -2134,15 +2134,22 @@ void ObjectDB::cleanup() {
|
||||||
|
|
||||||
WARN_PRINT("ObjectDB instances leaked at exit (run with --verbose for details).");
|
WARN_PRINT("ObjectDB instances leaked at exit (run with --verbose for details).");
|
||||||
if (OS::get_singleton()->is_stdout_verbose()) {
|
if (OS::get_singleton()->is_stdout_verbose()) {
|
||||||
|
// Ensure calling the native classes because if a leaked instance has a script
|
||||||
|
// that overrides any of those methods, it'd not be OK to call them at this point,
|
||||||
|
// now the scripting languages have already been terminated.
|
||||||
|
MethodBind *node_get_name = ClassDB::get_method("Node", "get_name");
|
||||||
|
MethodBind *resource_get_path = ClassDB::get_method("Resource", "get_path");
|
||||||
|
Variant::CallError call_error;
|
||||||
|
|
||||||
const ObjectID *K = NULL;
|
const ObjectID *K = NULL;
|
||||||
while ((K = instances.next(K))) {
|
while ((K = instances.next(K))) {
|
||||||
|
|
||||||
String node_name;
|
String extra_info;
|
||||||
if (instances[*K]->is_class("Node"))
|
if (instances[*K]->is_class("Node"))
|
||||||
node_name = " - Node name: " + String(instances[*K]->call("get_name"));
|
extra_info = " - Node name: " + String(node_get_name->call(instances[*K], NULL, 0, call_error));
|
||||||
if (instances[*K]->is_class("Resource"))
|
if (instances[*K]->is_class("Resource"))
|
||||||
node_name = " - Resource path: " + String(instances[*K]->call("get_path"));
|
extra_info = " - Resource path: " + String(resource_get_path->call(instances[*K], NULL, 0, call_error));
|
||||||
print_line("Leaked instance: " + String(instances[*K]->get_class()) + ":" + itos(*K) + node_name);
|
print_line("Leaked instance: " + String(instances[*K]->get_class()) + ":" + itos(*K) + extra_info);
|
||||||
}
|
}
|
||||||
print_line("Hint: Leaked instances typically happen when nodes are removed from the scene tree (with `remove_child()`) but not freed (with `free()` or `queue_free()`).");
|
print_line("Hint: Leaked instances typically happen when nodes are removed from the scene tree (with `remove_child()`) but not freed (with `free()` or `queue_free()`).");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue