Clear canvas item after rendering font, fixes #23774

This commit is contained in:
Juan Linietsky 2019-02-23 21:30:39 -03:00
parent e30ce69cb4
commit f436047cf5

View file

@ -845,15 +845,16 @@ Ref<Texture> EditorFontPreviewPlugin::generate_from_path(const String &p_path, c
font->draw(canvas_item, pos, sampled_text);
VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture
preview_done = false;
VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture
VS::get_singleton()->request_frame_drawn_callback(const_cast<EditorFontPreviewPlugin *>(this), "_preview_done", Variant());
while (!preview_done) {
OS::get_singleton()->delay_usec(10);
}
VS::get_singleton()->canvas_item_clear(canvas_item);
Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture);
ERR_FAIL_COND_V(img.is_null(), Ref<ImageTexture>());
@ -878,7 +879,11 @@ Ref<Texture> EditorFontPreviewPlugin::generate_from_path(const String &p_path, c
Ref<Texture> EditorFontPreviewPlugin::generate(const RES &p_from, const Size2 p_size) const {
return generate_from_path(p_from->get_path(), p_size);
String path = p_from->get_path();
if (!FileAccess::exists(path)) {
return Ref<Texture>();
}
return generate_from_path(path, p_size);
}
EditorFontPreviewPlugin::EditorFontPreviewPlugin() {