From 3ed92311175bb7024d7b51e7c70acbeaaf0b4947 Mon Sep 17 00:00:00 2001 From: Will Nations Date: Wed, 15 Aug 2018 09:12:35 -0500 Subject: [PATCH] Fix error spam from loading script class icons --- editor/create_dialog.cpp | 15 +++++++++------ modules/gdscript/gdscript.cpp | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index ab7a7054eb8..0bc42446421 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -158,12 +158,15 @@ Ref CreateDialog::_get_editor_icon(const String &p_type) const { } if (ScriptServer::is_global_class(p_type)) { - RES icon = ResourceLoader::load(EditorNode::get_editor_data().script_class_get_icon_path(p_type)); - if (icon.is_valid()) - return icon; - icon = get_icon(ScriptServer::get_global_class_base(p_type), "EditorIcons"); - if (icon.is_valid()) - return icon; + String icon_path = EditorNode::get_editor_data().script_class_get_icon_path(p_type); + RES icon; + if (FileAccess::exists(icon_path)) { + icon = ResourceLoader::load(icon_path); + } + if (!icon.is_valid()) { + icon = get_icon(ScriptServer::get_global_class_base(p_type), "EditorIcons"); + } + return icon; } const Map > &p_map = EditorNode::get_editor_data().get_custom_types(); diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 8cf7121630f..b987d2897ff 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -1877,7 +1877,7 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b } } if (r_icon_path) { - if (c->icon_path.is_abs_path()) + if (c->icon_path.empty() || c->icon_path.is_abs_path()) *r_icon_path = c->icon_path; else if (c->icon_path.is_rel_path()) *r_icon_path = p_path.get_base_dir().plus_file(c->icon_path).simplify_path();