summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorJuan Linietsky <juan@godotengine.org>2019-02-23 21:30:39 -0300
committerJuan Linietsky <juan@godotengine.org>2019-02-23 21:31:09 -0300
commitf436047cf584271edea0e87d8765e1a0c72dcd66 (patch)
tree95546b6e08f5e9a08176313d24bfc6002a625a20 /editor/plugins
parente30ce69cb44cd31933dc81700d16db2c80727015 (diff)
Clear canvas item after rendering font, fixes #23774
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/editor_preview_plugins.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index 071a0287e6..3cf46e5b91 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -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() {