From d83057120bb4bbf4be28e00949750302e43fba02 Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Sat, 25 Jan 2020 21:27:54 +0200 Subject: [PATCH] Fixed crash when importing images that were failing to load They still fail to load, but Pixelorama does not crash. --- Changelog.md | 6 ++++++ Scripts/Dialogs/ImportSprites.gd | 14 +++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Changelog.md b/Changelog.md index 6c8db125b..d74cfbf92 100644 --- a/Changelog.md +++ b/Changelog.md @@ -10,9 +10,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Spanish translation - thanks to azagaya! - Translators can now be seen in the About window. +## Changed +- Updates to the Greek, Russian and Traditional Chinese translations. +- Replaced some OS alerts with a custom made error dialog. + ### Fixed - Delay the splash screen popup so it shows properly centered (thanks to YeldhamDev) - Possibly fixed crashes with motion drawing and undo/redoing. +- Fixed bug (which also caused crashes sometimes) when generating an outline inside the image and it was going outside the canvas' borders. +- Fixed crash when importing images that were failing to load. They still fail to load, but Pixelorama does not crash. ## [v0.6.1] - 13-01-2020 diff --git a/Scripts/Dialogs/ImportSprites.gd b/Scripts/Dialogs/ImportSprites.gd index 2479cc6e9..643f9e5c1 100644 --- a/Scripts/Dialogs/ImportSprites.gd +++ b/Scripts/Dialogs/ImportSprites.gd @@ -35,8 +35,7 @@ func _on_ImportSprites_files_selected(paths : PoolStringArray) -> void: Global.control.clear_canvases() var first_path : String = paths[0] - var i: int = Global.canvases.size() - + var i : int = Global.canvases.size() if !import_spritesheet: # Find the biggest image and let it handle the camera zoom options var max_size : Vector2 @@ -45,7 +44,9 @@ func _on_ImportSprites_files_selected(paths : PoolStringArray) -> void: var image := Image.new() var err := image.load(path) if err != OK: # An error occured - OS.alert("Can't load file") + var file_name : String = path.get_file() + Global.error_dialog.set_text("Can't load file '%s'.\nError code: %s" % [file_name, str(err)]) + Global.error_dialog.popup_centered() continue var canvas : Canvas = load("res://Prefabs/Canvas.tscn").instance() @@ -69,13 +70,16 @@ func _on_ImportSprites_files_selected(paths : PoolStringArray) -> void: i += 1 - biggest_canvas.camera_zoom() + if biggest_canvas: + biggest_canvas.camera_zoom() else: var image := Image.new() var err := image.load(first_path) if err != OK: # An error occured - OS.alert("Can't load file") + var file_name : String = first_path.get_file() + Global.error_dialog.set_text("Can't load file '%s'.\nError code: %s" % [file_name, str(err)]) + Global.error_dialog.popup_centered() return spritesheet_horizontal = min(spritesheet_horizontal, image.get_size().x)