Browse Source

Object: Add missing lock

Pedro J. Estébanez 1 year ago
parent
commit
b834037841
1 changed files with 4 additions and 3 deletions
  1. 4 3
      core/object/object.cpp

+ 4 - 3
core/object/object.cpp

@@ -2307,9 +2307,9 @@ void ObjectDB::setup() {
 }
 }
 
 
 void ObjectDB::cleanup() {
 void ObjectDB::cleanup() {
-	if (slot_count > 0) {
-		spin_lock.lock();
+	spin_lock.lock();
 
 
+	if (slot_count > 0) {
 		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
 			// Ensure calling the native classes because if a leaked instance has a script
@@ -2340,10 +2340,11 @@ void ObjectDB::cleanup() {
 			}
 			}
 			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()`).");
 		}
 		}
-		spin_lock.unlock();
 	}
 	}
 
 
 	if (object_slots) {
 	if (object_slots) {
 		memfree(object_slots);
 		memfree(object_slots);
 	}
 	}
+
+	spin_lock.unlock();
 }
 }