aboutsummaryrefslogtreecommitdiff
path: root/editor/export_template_manager.cpp
diff options
context:
space:
mode:
authorMarcin Zawiejski2018-02-07 16:18:14 +0100
committerHein-Pieter van Braam2018-02-19 22:13:46 +0100
commite6252bda5ecc429caac2fd7fc07bbeceb9545feb (patch)
tree82aa3295187aaa55e8de40ebfec1d3322fd0c264 /editor/export_template_manager.cpp
parent069658f1be01bbfedae721e4539a2b683d048cc6 (diff)
downloadgodot-e6252bda5ecc429caac2fd7fc07bbeceb9545feb.tar.gz
godot-e6252bda5ecc429caac2fd7fc07bbeceb9545feb.tar.zst
godot-e6252bda5ecc429caac2fd7fc07bbeceb9545feb.zip
download templates to a file using separate thread
(cherry picked from commit b4f1a035e327b6e9f0f4a02040175b23bf5eac3f)
Diffstat (limited to '')
-rw-r--r--editor/export_template_manager.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp
index 6cbca3f73..0363b2eaa 100644
--- a/editor/export_template_manager.cpp
+++ b/editor/export_template_manager.cpp
@@ -400,19 +400,10 @@ void ExportTemplateManager::_http_download_templates_completed(int p_status, int
if (p_code != 200) {
template_list_state->set_text(TTR("Failed:") + " " + itos(p_code));
} else {
- String path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmp_templates.tpz");
- FileAccess *f = FileAccess::open(path, FileAccess::WRITE);
- if (!f) {
- template_list_state->set_text(TTR("Can't write file."));
- } else {
- int size = p_data.size();
- PoolVector<uint8_t>::Read r = p_data.read();
- f->store_buffer(r.ptr(), size);
- memdelete(f);
- template_list_state->set_text(TTR("Download Complete."));
- template_downloader->hide();
- _install_from_file(path, false);
- }
+ String path = download_templates->get_download_file();
+ template_list_state->set_text(TTR("Download Complete."));
+ template_downloader->hide();
+ _install_from_file(path, false);
}
} break;
}
@@ -430,6 +421,8 @@ void ExportTemplateManager::_begin_template_download(const String &p_url) {
}
download_data.clear();
+ download_templates->set_download_file(EditorSettings::get_singleton()->get_cache_dir().plus_file("tmp_templates.tpz"));
+ download_templates->set_use_threads(true);
Error err = download_templates->request(p_url);
if (err != OK) {