Skip to content

Commit

Permalink
Added try catch for GetThumbnail
Browse files Browse the repository at this point in the history
  • Loading branch information
mantaionut committed Feb 11, 2025
1 parent fb35c93 commit 78d35ef
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/modules/launcher/Wox.Infrastructure/Image/ImageLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,30 @@ private static ImageResult GetThumbnailResult(ref string path, bool generateThum
// To not run into the crash, we only request the icon of PDF files if the PDF thumbnail handler is set to Adobe Reader/Acrobat Pro.
// Also don't get thumbnail if the GenerateThumbnailsFromFiles option is off.
type = ImageType.File;
image = WindowsThumbnailProvider.GetThumbnail(path, Constant.ThumbnailSize, Constant.ThumbnailSize, ThumbnailOptions.IconOnly);
Log.Info($"GetThumbnailResult generateThumbnailsFromFiles false for {path}", MethodBase.GetCurrentMethod().DeclaringType);
try
{
image = WindowsThumbnailProvider.GetThumbnail(path, Constant.ThumbnailSize, Constant.ThumbnailSize, ThumbnailOptions.IconOnly);
}
catch (System.Exception e)
{
Log.Exception($"Exception in GetThumbnail for {path}", e, MethodBase.GetCurrentMethod().DeclaringType);
image = ImageCache[ErrorIconPath];
}
}
else
{
type = ImageType.File;
image = WindowsThumbnailProvider.GetThumbnail(path, Constant.ThumbnailSize, Constant.ThumbnailSize, ThumbnailOptions.RESIZETOFIT);
Log.Info($"GetThumbnailResult generateThumbnailsFromFiles true for {path}", MethodBase.GetCurrentMethod().DeclaringType);
try
{
image = WindowsThumbnailProvider.GetThumbnail(path, Constant.ThumbnailSize, Constant.ThumbnailSize, ThumbnailOptions.RESIZETOFIT);
}
catch (System.Exception e)
{
Log.Exception($"Exception in GetThumbnail for {path}", e, MethodBase.GetCurrentMethod().DeclaringType);
image = ImageCache[ErrorIconPath];
}
}
}
else
Expand Down

0 comments on commit 78d35ef

Please # to comment.