diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2023-06-19 16:18:39 +0300 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2023-07-03 13:48:28 +0300 |
commit | 9c5a0c6c102556c229825e053153d02fb7141668 (patch) | |
tree | 026374922e004f48fae8057f982f2d3c26c5018a /platform/web/js/libs | |
parent | 46424488edc341b65467ee7fd3ac423e4d49ad34 (diff) | |
download | redot-engine-9c5a0c6c102556c229825e053153d02fb7141668.tar.gz |
Add error checks and harmonize behavior of the set_icon method.
Diffstat (limited to 'platform/web/js/libs')
-rw-r--r-- | platform/web/js/libs/library_godot_display.js | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/platform/web/js/libs/library_godot_display.js b/platform/web/js/libs/library_godot_display.js index 23cbc67c16..f8f38337d5 100644 --- a/platform/web/js/libs/library_godot_display.js +++ b/platform/web/js/libs/library_godot_display.js @@ -568,16 +568,23 @@ const GodotDisplay = { godot_js_display_window_icon_set__sig: 'vii', godot_js_display_window_icon_set: function (p_ptr, p_len) { let link = document.getElementById('-gd-engine-icon'); - if (link === null) { - link = document.createElement('link'); - link.rel = 'icon'; - link.id = '-gd-engine-icon'; - document.head.appendChild(link); - } const old_icon = GodotDisplay.window_icon; - const png = new Blob([GodotRuntime.heapSlice(HEAPU8, p_ptr, p_len)], { type: 'image/png' }); - GodotDisplay.window_icon = URL.createObjectURL(png); - link.href = GodotDisplay.window_icon; + if (p_ptr) { + if (link === null) { + link = document.createElement('link'); + link.rel = 'icon'; + link.id = '-gd-engine-icon'; + document.head.appendChild(link); + } + const png = new Blob([GodotRuntime.heapSlice(HEAPU8, p_ptr, p_len)], { type: 'image/png' }); + GodotDisplay.window_icon = URL.createObjectURL(png); + link.href = GodotDisplay.window_icon; + } else { + if (link) { + link.remove(); + } + GodotDisplay.window_icon = null; + } if (old_icon) { URL.revokeObjectURL(old_icon); } |