瀏覽代碼

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

Ruben 1 月之前
父節點
當前提交
8e81c7b2d9
共有 1 個文件被更改,包括 16 次插入4 次删除
  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);
+                    }
                 }
             }
         }