Skip to content

Commit d743dcc

Browse files
committed
Merge pull request #109766 from bruvzg/broken_links
Fix editor resource tooltip crash on broken symlinks.
2 parents 8ebf8ae + 95b71e1 commit d743dcc

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

editor/inspector/editor_resource_tooltip_plugins.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
#include "editor_resource_tooltip_plugins.h"
3232

33+
#include "editor/editor_node.h"
34+
#include "editor/editor_string_names.h"
3335
#include "editor/file_system/editor_file_system.h"
3436
#include "editor/inspector/editor_resource_preview.h"
3537
#include "editor/themes/editor_scale.h"
@@ -72,8 +74,15 @@ VBoxContainer *EditorResourceTooltipPlugin::make_default_tooltip(const String &p
7274

7375
{
7476
Ref<FileAccess> f = FileAccess::open(p_resource_path, FileAccess::READ);
75-
Label *label = memnew(Label(vformat(TTR("Size: %s"), String::humanize_size(f->get_length()))));
76-
vb->add_child(label);
77+
if (f.is_valid()) {
78+
Label *label = memnew(Label(vformat(TTR("Size: %s"), String::humanize_size(f->get_length()))));
79+
vb->add_child(label);
80+
} else {
81+
Label *label = memnew(Label(TTR("Invalid file or broken link.")));
82+
label->add_theme_color_override(SceneStringName(font_color), EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
83+
vb->add_child(label);
84+
return vb;
85+
}
7786
}
7887

7988
if (ResourceLoader::exists(p_resource_path)) {

0 commit comments

Comments
 (0)