Browse Source

More catches and fixes

Krzysztof Krysiński 2 years ago
parent
commit
b337d4321c

+ 2 - 1
src/PixiEditor/Models/IO/Importer.cs

@@ -28,8 +28,9 @@ internal class Importer : NotifyableObject
     /// <param name="path">Path of the image.</param>
     /// <param name="size">New size of the image.</param>
     /// <returns>WriteableBitmap of imported image.</returns>
-    public static Surface ImportImage(string path, VecI size)
+    public static Surface? ImportImage(string path, VecI size)
     {
+        if (!Path.Exists(path)) return null;
         Surface original = Surface.Load(path);
         if (original.Size == size || size == VecI.NegativeOne)
         {

+ 2 - 0
src/PixiEditor/ViewModels/SubViewModels/Main/FileViewModel.cs

@@ -230,6 +230,8 @@ internal class FileViewModel : SubViewModel<ViewModelMain>
     {
         var image = Importer.ImportImage(path, VecI.NegativeOne);
 
+        if (image == null) return;
+
         var doc = NewDocument(b => b
             .WithSize(image.Size)
             .WithLayer(l => l

+ 4 - 0
src/PixiEditor/ViewModels/SubViewModels/Main/UpdateViewModel.cs

@@ -97,6 +97,10 @@ internal class UpdateViewModel : SubViewModel<ViewModelMain>
                 NoticeDialog.Show("FAILED_DOWNLOADING_TITLE", "FAILED_DOWNLOADING");
                 return false;
             }
+            catch(TaskCanceledException ex)
+            {
+                return false;
+            }
 
             return true;
         }