diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-07-28 00:31:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-28 00:31:46 +0200 |
commit | 4e825539e590c6ce06e54fbb05571efce7fb181c (patch) | |
tree | 662a6a08ed32be814d315aaa7852ae4595aa8e00 | |
parent | 5f28ab6566a4e12b802f06584ead65e640c295f1 (diff) | |
parent | 0e54ba0486e65af74f8b7729b09e42de5495d8ec (diff) | |
download | redot-engine-4e825539e590c6ce06e54fbb05571efce7fb181c.tar.gz |
Merge pull request #40762 from SkyLucilfer/PackedSceneLeak
Fix EditorTranslationParser leak
-rw-r--r-- | editor/editor_node.cpp | 1 | ||||
-rw-r--r-- | editor/editor_translation_parser.cpp | 5 | ||||
-rw-r--r-- | editor/editor_translation_parser.h | 1 | ||||
-rw-r--r-- | modules/gdscript/register_types.cpp | 8 |
4 files changed, 8 insertions, 7 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 7eb5b3094d..ce131e6a05 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -6799,6 +6799,7 @@ EditorNode::EditorNode() { EditorNode::~EditorNode() { EditorInspector::cleanup_plugins(); + EditorTranslationParser::get_singleton()->clean_parsers(); remove_print_handler(&print_handler); memdelete(EditorHelp::get_doc_data()); diff --git a/editor/editor_translation_parser.cpp b/editor/editor_translation_parser.cpp index 3f4864ad1e..da191fbc92 100644 --- a/editor/editor_translation_parser.cpp +++ b/editor/editor_translation_parser.cpp @@ -147,6 +147,11 @@ void EditorTranslationParser::remove_parser(const Ref<EditorTranslationParserPlu } } +void EditorTranslationParser::clean_parsers() { + standard_parsers.clear(); + custom_parsers.clear(); +} + EditorTranslationParser *EditorTranslationParser::get_singleton() { if (!singleton) { singleton = memnew(EditorTranslationParser); diff --git a/editor/editor_translation_parser.h b/editor/editor_translation_parser.h index 6d00bedfa4..fb8aa6ec9b 100644 --- a/editor/editor_translation_parser.h +++ b/editor/editor_translation_parser.h @@ -64,6 +64,7 @@ public: Ref<EditorTranslationParserPlugin> get_parser(const String &p_extension) const; void add_parser(const Ref<EditorTranslationParserPlugin> &p_parser, ParserType p_type); void remove_parser(const Ref<EditorTranslationParserPlugin> &p_parser, ParserType p_type); + void clean_parsers(); EditorTranslationParser(); ~EditorTranslationParser(); diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp index 23c7f97b5a..5c1d2f6f1b 100644 --- a/modules/gdscript/register_types.cpp +++ b/modules/gdscript/register_types.cpp @@ -57,8 +57,6 @@ GDScriptCache *gdscript_cache = nullptr; #include "language_server/gdscript_language_server.h" #endif // !GDSCRIPT_NO_LSP -Ref<GDScriptEditorTranslationParserPlugin> gdscript_translation_parser_plugin; - class EditorExportGDScript : public EditorExportPlugin { GDCLASS(EditorExportGDScript, EditorExportPlugin); @@ -122,6 +120,7 @@ void register_gdscript_types() { #ifdef TOOLS_ENABLED EditorNode::add_init_callback(_editor_init); + Ref<GDScriptEditorTranslationParserPlugin> gdscript_translation_parser_plugin; gdscript_translation_parser_plugin.instance(); EditorTranslationParser::get_singleton()->add_parser(gdscript_translation_parser_plugin, EditorTranslationParser::STANDARD); #endif // TOOLS_ENABLED @@ -143,9 +142,4 @@ void unregister_gdscript_types() { ResourceSaver::remove_resource_format_saver(resource_saver_gd); resource_saver_gd.unref(); - -#ifdef TOOLS_ENABLED - EditorTranslationParser::get_singleton()->remove_parser(gdscript_translation_parser_plugin, EditorTranslationParser::STANDARD); - gdscript_translation_parser_plugin.unref(); -#endif // TOOLS_ENABLED } |