Browse Source

Destroy EditorFilesystem/EditorSettings on test shutdown

Otherwise asan complains if a test tries to use these.

Split off from https://github.com/godotengine/godot/pull/98909
demolke 9 months ago
parent
commit
35bb827d10
3 changed files with 8 additions and 0 deletions
  1. 4 0
      editor/editor_file_system.cpp
  2. 1 0
      editor/editor_paths.cpp
  3. 3 0
      tests/test_main.cpp

+ 4 - 0
editor/editor_file_system.cpp

@@ -3556,5 +3556,9 @@ EditorFileSystem::EditorFileSystem() {
 }
 
 EditorFileSystem::~EditorFileSystem() {
+	if (filesystem) {
+		memdelete(filesystem);
+	}
+	filesystem = nullptr;
 	ResourceSaver::set_get_resource_id_for_path(nullptr);
 }

+ 1 - 0
editor/editor_paths.cpp

@@ -105,6 +105,7 @@ void EditorPaths::create() {
 void EditorPaths::free() {
 	ERR_FAIL_NULL(singleton);
 	memdelete(singleton);
+	singleton = nullptr;
 }
 
 void EditorPaths::_bind_methods() {

+ 3 - 0
tests/test_main.cpp

@@ -370,6 +370,9 @@ struct GodotTestCaseListener : public doctest::IReporter {
 		if (EditorSettings::get_singleton()) {
 			EditorSettings::destroy();
 		}
+		if (EditorPaths::get_singleton()) {
+			EditorPaths::free();
+		}
 #endif // TOOLS_ENABLED
 
 		Engine::get_singleton()->set_editor_hint(false);