Skip to content

Commit 671d6e3

Browse files
committed
Merge pull request #98150 from hunterloftis/fix-default-import-threaded
Fix freeze on non-thread-safe custom importers
2 parents 77d6283 + bbb8c17 commit 671d6e3

17 files changed

+29
-7
lines changed

core/io/resource_importer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class ResourceImporter : public RefCounted {
148148
virtual String get_option_group_file() const { return String(); }
149149

150150
virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) = 0;
151-
virtual bool can_import_threaded() const { return true; }
151+
virtual bool can_import_threaded() const { return false; }
152152
virtual void import_threaded_begin() {}
153153
virtual void import_threaded_end() {}
154154

doc/classes/EditorImportPlugin.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@
124124
<return type="bool" />
125125
<description>
126126
Tells whether this importer can be run in parallel on threads, or, on the contrary, it's only safe for the editor to call it from the main thread, for one file at a time.
127-
If this method is not overridden, it will return [code]true[/code] by default (i.e., safe for parallel importing).
127+
If this method is not overridden, it will return [code]false[/code] by default.
128+
If this importer's implementation is thread-safe and can be run in parallel, override this with [code]true[/code] to optimize for concurrency.
128129
</description>
129130
</method>
130131
<method name="_get_import_options" qualifiers="virtual const">

editor/import/3d/resource_importer_obj.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ class ResourceImporterOBJ : public ResourceImporter {
6363

6464
virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
6565

66-
// Threaded import can currently cause deadlocks, see GH-48265.
67-
virtual bool can_import_threaded() const override { return false; }
68-
6966
ResourceImporterOBJ();
7067
};
7168

editor/import/3d/resource_importer_scene.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,6 @@ class ResourceImporterScene : public ResourceImporter {
304304
virtual bool has_advanced_options() const override;
305305
virtual void show_advanced_options(const String &p_path) override;
306306

307-
virtual bool can_import_threaded() const override { return false; }
308-
309307
ResourceImporterScene(const String &p_scene_import_type = "PackedScene", bool p_singleton = false);
310308
~ResourceImporterScene();
311309

editor/import/resource_importer_bitmask.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class ResourceImporterBitMap : public ResourceImporter {
5050
virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override;
5151
virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
5252

53+
virtual bool can_import_threaded() const override { return true; }
54+
5355
ResourceImporterBitMap();
5456
~ResourceImporterBitMap();
5557
};

editor/import/resource_importer_bmfont.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class ResourceImporterBMFont : public ResourceImporter {
5050

5151
virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
5252

53+
virtual bool can_import_threaded() const override { return true; }
54+
5355
ResourceImporterBMFont();
5456
};
5557

editor/import/resource_importer_csv_translation.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class ResourceImporterCSVTranslation : public ResourceImporter {
5151

5252
virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
5353

54+
virtual bool can_import_threaded() const override { return true; }
55+
5456
ResourceImporterCSVTranslation();
5557
};
5658

editor/import/resource_importer_dynamic_font.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ class ResourceImporterDynamicFont : public ResourceImporter {
6060

6161
virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
6262

63+
virtual bool can_import_threaded() const override { return true; }
64+
6365
ResourceImporterDynamicFont();
6466
};
6567

editor/import/resource_importer_image.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class ResourceImporterImage : public ResourceImporter {
5252

5353
virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
5454

55+
virtual bool can_import_threaded() const override { return true; }
56+
5557
ResourceImporterImage();
5658
};
5759

editor/import/resource_importer_imagefont.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class ResourceImporterImageFont : public ResourceImporter {
5050

5151
virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
5252

53+
virtual bool can_import_threaded() const override { return true; }
54+
5355
ResourceImporterImageFont();
5456
};
5557

0 commit comments

Comments
 (0)