Parcourir la source

Fix startup zoom crash by adding null checks for `_zoomIn` and `_zoomOut` in `MouseShortcuts` to prevent potential exceptions.

Ruben il y a 1 mois
Parent
commit
8e81c7b2d9
1 fichiers modifiés avec 16 ajouts et 4 suppressions
  1. 16 4
      src/PicView.Avalonia/Input/MouseShortcuts.cs

+ 16 - 4
src/PicView.Avalonia/Input/MouseShortcuts.cs

@@ -79,11 +79,17 @@ public static class MouseShortcuts
 
                 if (reverse)
                 {
-                    await _zoomOut(e);
+                    if (_zoomOut is not null)
+                    {
+                        await _zoomOut(e);
+                    }
                 }
                 else
                 {
-                    await _zoomIn(e);
+                    if (_zoomIn is not null)
+                    {
+                        await _zoomIn(e);
+                    }
                 }
             }
             else
@@ -101,11 +107,17 @@ public static class MouseShortcuts
             {
                 if (reverse)
                 {
-                    await _zoomOut(e);
+                    if (_zoomOut is not null)
+                    {
+                        await _zoomOut(e);
+                    }
                 }
                 else
                 {
-                    await _zoomIn(e);
+                    if (_zoomIn is not null)
+                    {
+                        await _zoomIn(e);
+                    }
                 }
             }
         }