Merge pull request #40762 from SkyLucilfer/PackedSceneLeak

Fix EditorTranslationParser leak
This commit is contained in:
Rémi Verschelde 2020-07-28 00:31:46 +02:00 committed by GitHub
commit 4e825539e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 7 deletions

View File

@ -6799,6 +6799,7 @@ EditorNode::EditorNode() {
EditorNode::~EditorNode() { EditorNode::~EditorNode() {
EditorInspector::cleanup_plugins(); EditorInspector::cleanup_plugins();
EditorTranslationParser::get_singleton()->clean_parsers();
remove_print_handler(&print_handler); remove_print_handler(&print_handler);
memdelete(EditorHelp::get_doc_data()); memdelete(EditorHelp::get_doc_data());

View File

@ -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() { EditorTranslationParser *EditorTranslationParser::get_singleton() {
if (!singleton) { if (!singleton) {
singleton = memnew(EditorTranslationParser); singleton = memnew(EditorTranslationParser);

View File

@ -64,6 +64,7 @@ public:
Ref<EditorTranslationParserPlugin> get_parser(const String &p_extension) const; Ref<EditorTranslationParserPlugin> get_parser(const String &p_extension) const;
void add_parser(const Ref<EditorTranslationParserPlugin> &p_parser, ParserType p_type); void add_parser(const Ref<EditorTranslationParserPlugin> &p_parser, ParserType p_type);
void remove_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();
~EditorTranslationParser(); ~EditorTranslationParser();

View File

@ -57,8 +57,6 @@ GDScriptCache *gdscript_cache = nullptr;
#include "language_server/gdscript_language_server.h" #include "language_server/gdscript_language_server.h"
#endif // !GDSCRIPT_NO_LSP #endif // !GDSCRIPT_NO_LSP
Ref<GDScriptEditorTranslationParserPlugin> gdscript_translation_parser_plugin;
class EditorExportGDScript : public EditorExportPlugin { class EditorExportGDScript : public EditorExportPlugin {
GDCLASS(EditorExportGDScript, EditorExportPlugin); GDCLASS(EditorExportGDScript, EditorExportPlugin);
@ -122,6 +120,7 @@ void register_gdscript_types() {
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
EditorNode::add_init_callback(_editor_init); EditorNode::add_init_callback(_editor_init);
Ref<GDScriptEditorTranslationParserPlugin> gdscript_translation_parser_plugin;
gdscript_translation_parser_plugin.instance(); gdscript_translation_parser_plugin.instance();
EditorTranslationParser::get_singleton()->add_parser(gdscript_translation_parser_plugin, EditorTranslationParser::STANDARD); EditorTranslationParser::get_singleton()->add_parser(gdscript_translation_parser_plugin, EditorTranslationParser::STANDARD);
#endif // TOOLS_ENABLED #endif // TOOLS_ENABLED
@ -143,9 +142,4 @@ void unregister_gdscript_types() {
ResourceSaver::remove_resource_format_saver(resource_saver_gd); ResourceSaver::remove_resource_format_saver(resource_saver_gd);
resource_saver_gd.unref(); 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
} }