Skip to content

Commit

Permalink
-Fix problem of order of import plugins, closes #26340
Browse files Browse the repository at this point in the history
-Ensure resource previewer does not start until first import is done
  • Loading branch information
reduz committed Feb 27, 2019
1 parent ce615c1 commit a5370b1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
9 changes: 7 additions & 2 deletions core/io/resource_importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,14 @@ bool ResourceFormatImporter::are_import_settings_valid(const String &p_path) con
}

String ResourceFormatImporter::get_import_settings_hash() const {

Vector<Ref<ResourceImporter> > sorted_importers = importers;

sorted_importers.sort_custom<SortImporterByName>();

String hash;
for (int i = 0; i < importers.size(); i++) {
hash += ":" + importers[i]->get_importer_name() + ":" + importers[i]->get_import_settings_string();
for (int i = 0; i < sorted_importers.size(); i++) {
hash += ":" + sorted_importers[i]->get_importer_name() + ":" + sorted_importers[i]->get_import_settings_string();
}
return hash.md5_text();
}
Expand Down
1 change: 0 additions & 1 deletion core/io/resource_importer.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class ResourceFormatImporter : public ResourceFormatLoader {

void add_importer(const Ref<ResourceImporter> &p_importer) {
importers.push_back(p_importer);
importers.sort_custom<SortImporterByName>();
}
void remove_importer(const Ref<ResourceImporter> &p_importer) { importers.erase(p_importer); }
Ref<ResourceImporter> get_importer_by_name(const String &p_name) const;
Expand Down
2 changes: 2 additions & 0 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,8 @@ void EditorNode::_sources_changed(bool p_exist) {

if (waiting_for_first_scan) {

EditorResourcePreview::get_singleton()->start(); //start previes now that it's safe

_load_docks();

if (defer_load_scene != "") {
Expand Down
7 changes: 5 additions & 2 deletions editor/editor_resource_preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,10 @@ void EditorResourcePreview::check_for_invalidation(const String &p_path) {
}
}

void EditorResourcePreview::start() {
ERR_FAIL_COND(thread);
thread = Thread::create(_thread_func, this);
}
void EditorResourcePreview::stop() {
if (thread) {
exit = true;
Expand All @@ -428,13 +432,12 @@ void EditorResourcePreview::stop() {
}

EditorResourcePreview::EditorResourcePreview() {
thread = NULL;
singleton = this;
preview_mutex = Mutex::create();
preview_sem = Semaphore::create();
order = 0;
exit = false;

thread = Thread::create(_thread_func, this);
}

EditorResourcePreview::~EditorResourcePreview() {
Expand Down
1 change: 1 addition & 0 deletions editor/editor_resource_preview.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class EditorResourcePreview : public Node {
void remove_preview_generator(const Ref<EditorResourcePreviewGenerator> &p_generator);
void check_for_invalidation(const String &p_path);

void start();
void stop();

EditorResourcePreview();
Expand Down

0 comments on commit a5370b1

Please sign in to comment.