Ruben2776 / PicView

Fast, free and customizable image viewer for Windows 10 and 11.

Home Page:https://picview.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Zoom causes crash

nopeless opened this issue · comments

Zooming in without image is loaded crashes the application

Null reference error and I believe this is an easy bug to fix. If you are unsure what I am referring to let me know

@me505 If you are interested in this, the project compiles out of the box (fresh clone just compiles straight away). The offending method is here

/// <summary>
/// Zooms in or out the <see cref="ConfigureWindows.GetMainWindow.MainImage"/> by the given amount.
/// </summary>
/// <param name="isZoomIn">Determines whether to zoom in or out.</param>
internal static void Zoom(bool isZoomIn)
{
// Disable zoom if cropping tool is active
if (UC.GetCroppingTool != null && UC.GetCroppingTool.IsVisible)
{
return;
}
var currentZoom = ScaleTransform.ScaleX;
var zoomSpeed = Settings.Default.ZoomSpeed;
switch (currentZoom)
{
// Increase speed based on the current zoom level
case > 14 when isZoomIn:
return;
case > 4:
zoomSpeed += 1.5;
break;
case > 3.2:
zoomSpeed += 1;
break;
case > 1.6:
zoomSpeed += 0.5;
break;
}
if (!isZoomIn)
{
zoomSpeed = -zoomSpeed;
}
currentZoom += zoomSpeed;
currentZoom = Math.Max(0.09, currentZoom);
if (Settings.Default.AvoidZoomingOut && currentZoom < 1.0)
{
ResetZoom();
}
else
{
Zoom(currentZoom);
}
}

Just add a null check

What is this.

What is this.

Its a lightweight .NET WPF image viewer. Kinda like the "Photos" program that comes with a windows install

Thanks. It will be fixed in next release.