summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-07-27 16:27:25 +0200
committerGitHub <noreply@github.com>2020-07-27 16:27:25 +0200
commit09a2b77b2dba0fe129cfe0ab36f842ff8b528f2d (patch)
treeb7a4772aea574e26062449319882de4d5a20f2c6 /editor
parent94e6fcd2aa5a3247763c126033012b36bf94add0 (diff)
parente2b85b74a29e2a95c3d9c262e05bb4f166f45d26 (diff)
Merge pull request #40759 from pycbouh/fix-scene-preview-no-2d
Fix errors saving a 2D scene preview when the 2D editor was never opened
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_node.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 263ed9040a..7eb5b3094d 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -1236,7 +1236,10 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) {
img.instance();
img->create(1, 1, 0, Image::FORMAT_RGB8);
} else if (c3d < c2d) {
- img = scene_root->get_texture()->get_data();
+ Ref<ViewportTexture> viewport_texture = scene_root->get_texture();
+ if (viewport_texture->get_width() > 0 && viewport_texture->get_height() > 0) {
+ img = viewport_texture->get_data();
+ }
} else {
// The 3D editor may be disabled as a feature, but scenes can still be opened.
// This check prevents the preview from regenerating in case those scenes are then saved.
@@ -1246,7 +1249,7 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) {
}
}
- if (img.is_valid()) {
+ if (img.is_valid() && img->get_width() > 0 && img->get_height() > 0) {
img = img->duplicate();
save.step(TTR("Creating Thumbnail"), 2);