diff options
-rw-r--r-- | editor/editor_node.cpp | 7 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 6 |
2 files changed, 8 insertions, 5 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); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index edce2023ff..6c7f4eb908 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -2094,12 +2094,12 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra // Don't open dominant script if using an external editor. const bool use_external_editor = EditorSettings::get_singleton()->get("text_editor/external/use_external_editor") || - script->get_language()->overrides_external_editor(); + (script.is_valid() && script->get_language()->overrides_external_editor()); const bool open_dominant = EditorSettings::get_singleton()->get("text_editor/files/open_dominant_script_on_scene_change"); const bool should_open = (open_dominant && !use_external_editor) || !EditorNode::get_singleton()->is_changing_scene(); - if (script != nullptr && script->get_language()->overrides_external_editor()) { + if (script.is_valid() && script->get_language()->overrides_external_editor()) { if (should_open) { Error err = script->get_language()->open_in_external_editor(script, p_line >= 0 ? p_line : 0, p_col); if (err != OK) { @@ -3005,7 +3005,7 @@ void ScriptEditor::set_scene_root_script(Ref<Script> p_script) { // Don't open dominant script if using an external editor. const bool use_external_editor = EditorSettings::get_singleton()->get("text_editor/external/use_external_editor") || - p_script->get_language()->overrides_external_editor(); + (p_script.is_valid() && p_script->get_language()->overrides_external_editor()); const bool open_dominant = EditorSettings::get_singleton()->get("text_editor/files/open_dominant_script_on_scene_change"); if (open_dominant && !use_external_editor && p_script.is_valid()) { |