1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Core: Add hints to run with --verbose when leaking nodes/resources at exit

(cherry picked from commit 2b5545270a)
This commit is contained in:
Rémi Verschelde
2020-06-08 16:39:08 +02:00
parent 2652a2d184
commit ebb30ac45a
2 changed files with 14 additions and 12 deletions

View File

@@ -33,6 +33,7 @@
#include "core/core_string_names.h"
#include "core/io/resource_loader.h"
#include "core/os/file_access.h"
#include "core/os/os.h"
#include "core/script_language.h"
#include "scene/main/node.h" //only so casting works
@@ -472,21 +473,22 @@ void ResourceCache::setup() {
}
void ResourceCache::clear() {
if (resources.size())
ERR_PRINT("Resources Still in use at Exit!");
if (resources.size()) {
ERR_PRINT("Resources still in use at exit (run with --verbose for details).");
if (OS::get_singleton()->is_stdout_verbose()) {
const String *K = nullptr;
while ((K = resources.next(K))) {
Resource *r = resources[*K];
print_line(vformat("Resource still in use: %s (%s)", *K, r->get_class()));
}
}
}
resources.clear();
memdelete(lock);
}
void ResourceCache::reload_externals() {
/*
const String *K=NULL;
while ((K=resources.next(K))) {
resources[*K]->reload_external_data();
}
*/
}
bool ResourceCache::has(const String &p_path) {
@@ -573,6 +575,5 @@ void ResourceCache::dump(const char *p_file, bool p_short) {
}
lock->read_unlock();
#endif
}