BE-557: Fixed issue where BE would crash in certain cases where GetPropertyVa...
feb99cc5
StickNitro
committed
1 changed file
ToolTip.xaml.cs
/Shell/ToolTip.xaml.cs-15+30
/Shell/ToolTip.xaml.cs
Add comment 76 }
Add comment 77 Contents = Type == 0 ? $"{clonedCurrentItem.DisplayName}\r\n{clonedCurrentItem.ToolTipText}" : clonedCurrentItem.ToolTipText;
Add comment 78 RaisePropertyChanged("Contents");
Add comment 79 Minus   // BUG: clonedCurrentItem.GetPropertyValue returned VT_EMPTY, edge case included to handle this
Add comment 80 Minus   //var perceivedTypeProperty = clonedCurrentItem.GetPropertyValue(
Add comment 81 Minus   //SystemProperties.PerceivedType,
Add comment 82 Minus   //typeof(PerceivedType));
Add comment 83 Minus   if (/*perceivedTypeProperty.VarType != VarEnum.VT_EMPTY && */((PerceivedType)clonedCurrentItem.GetPropertyValue(SystemProperties.PerceivedType,typeof(PerceivedType)).Value) ==
Add comment 84 Minus   PerceivedType.Image && !clonedCurrentItem.IsFolder) {
Add comment 85 Minus   var image = clonedCurrentItem.ThumbnailSource(350, ShellThumbnailFormatOption.Default,
Add comment 79 Plus  
Add comment 80 Plus   // BE-557: clonedCurrentItem.GetPropertyValue returned VT_EMPTY, edge case included to handle this
Add comment 81 Plus   var perceivedTypeProperty = clonedCurrentItem.GetPropertyValue(
Add comment 82 Plus   SystemProperties.PerceivedType,
Add comment 83 Plus   typeof(PerceivedType));
Add comment 84 Plus   if (perceivedTypeProperty.VarType != VarEnum.VT_EMPTY
Add comment 85 Plus   && ((PerceivedType)perceivedTypeProperty.Value) == PerceivedType.Image && !clonedCurrentItem.IsFolder)
Add comment 86 Plus   {
Add comment 87 Plus   var image = clonedCurrentItem.ThumbnailSource(
Add comment 88 Plus   350,
Add comment 89 Plus   ShellThumbnailFormatOption.Default,
Add comment 86 90 ShellThumbnailRetrievalOption.Default);
Add comment 87 91 image.Freeze();
Add comment 88 92 this.Image = image;
Add comment 89 93 RaisePropertyChanged("Image");
Add comment 90 Minus   this.FileNameWidth = this.Image.Width - 110;
Add comment 94 Plus   this.FileNameWidth = this.Image.Width - 110;
Add comment 91 95 RaisePropertyChanged("FileNameWidth");
Add comment 92 96
Add comment 93 Minus   try {
Add comment 94 Minus   var ratingValue = clonedCurrentItem.GetPropertyValue(MediaProperties.Rating, typeof (Double)).Value;
Add comment 95 Minus   var rating = ratingValue == null ? 0 : Convert.ToDouble(ratingValue)/20D;
Add comment 97 Plus   try
Add comment 98 Plus   {
Add comment 99 Plus   var ratingValue = clonedCurrentItem.GetPropertyValue(MediaProperties.Rating, typeof(Double)).Value;
Add comment 100 Plus   var rating = ratingValue == null ? 0 : Convert.ToDouble(ratingValue) / 20D;
Add comment 96 101 this.Rating = rating;
Add comment 97 102 RaisePropertyChanged("Rating");
Add comment 98 Minus   this.Dimentions = ((Math.Ceiling(Convert.ToDouble(clonedCurrentItem.GetPropertyValue(SystemProperties.FileSize, typeof(double)).Value)) / 1024).ToString("# ### ### ##0") + " KB (" + clonedCurrentItem.GetPropertyValue(MediaProperties.Dimensions, typeof (String)).Value.ToString() + " px )").Trim();
Add comment 103 Plus   this.Dimentions =
Add comment 104 Plus   ((Math.Ceiling(
Add comment 105 Plus   Convert.ToDouble(clonedCurrentItem.GetPropertyValue(SystemProperties.FileSize, typeof(double)).Value))
Add comment 106 Plus   / 1024).ToString("# ### ### ##0") + " KB ("
Add comment 107 Plus   + clonedCurrentItem.GetPropertyValue(MediaProperties.Dimensions, typeof(String)).Value.ToString()
Add comment 108 Plus   + " px )").Trim();
Add comment 99 109 RaisePropertyChanged("Dimentions");
Add comment 100 110 }
Add comment 101 Minus   catch (NullReferenceException) { }
Add comment 111 Plus   catch (NullReferenceException)
Add comment 112 Plus   {
Add comment 113 Plus   }
Add comment 102 114 this.FileName = Path.GetFileName(clonedCurrentItem.ParsingName)?.Trim();
Add comment 103 115 RaisePropertyChanged("FileName");
Add comment 104 116 }
Add comment 105 Minus   else {
Add comment 106 Minus   var image = clonedCurrentItem.ThumbnailSource(64, ShellThumbnailFormatOption.Default,
Add comment 117 Plus   else
Add comment 118 Plus   {
Add comment 119 Plus   var image = clonedCurrentItem.ThumbnailSource(
Add comment 120 Plus   64,
Add comment 121 Plus   ShellThumbnailFormatOption.Default,
Add comment 107 122 ShellThumbnailRetrievalOption.Default);
Add comment 108 123 image.Freeze();
Add comment 109 124 this.Image = image;