Skip to content

Commit ea7618c

Browse files
Merge pull request #70 from fossmium/workaround-hashcode-mismatch
fix: Don't crash when GetHashCode doesn't match
2 parents c719283 + 9080fd4 commit ea7618c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

OneDrive-Cloud-Player/ViewModels/VideoPlayerPageViewModel.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -640,11 +640,14 @@ public void Activate(object mediaWrapper)
640640
{
641641
// Set the field so the playmedia method can use it.
642642
MediaWrapper = (MediaWrapper)mediaWrapper;
643-
MediaListIndex = App.Current.MediaItemList.IndexOf(MediaWrapper.CachedDriveItem);
643+
var list = App.Current.MediaItemList;
644644

645-
if (MediaListIndex < 0)
645+
// TODO: fix underlying issue where all properties of MediaWrapper.CachedDriveItem match
646+
// with an item in the list, but the hashcode doesn't. List.Contains works around this,
647+
// where IndexOf would return -1.
648+
if (list.Contains(MediaWrapper.CachedDriveItem))
646649
{
647-
throw new InvalidOperationException(String.Format("Object of type '{0}' not found.", (MediaWrapper.CachedDriveItem).GetType()));
650+
MediaListIndex = list.IndexOf(MediaWrapper.CachedDriveItem);
648651
}
649652
}
650653

0 commit comments

Comments
 (0)