Skip to content

Commit b225575

Browse files
committed
Verify ContentsChanged Event is Only Unassigned if it Exists
1 parent 17a3d6a commit b225575

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

Files UWP/Filesystem/ItemViewModel.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,14 @@ public async void AddItemsToCollectionAsync(string path, Page currentPage)
386386
rootContentFrame.Navigate(typeof(InstanceTabsView), null, new SuppressNavigationTransitionInfo());
387387
return;
388388
}
389+
catch (FileNotFoundException)
390+
{
391+
Frame rootContentFrame = Window.Current.Content as Frame;
392+
MessageDialog folderGone = new MessageDialog("The folder you've navigated to was removed.", "Did you delete this folder?");
393+
await folderGone.ShowAsync();
394+
rootContentFrame.Navigate(typeof(InstanceTabsView), null, new SuppressNavigationTransitionInfo());
395+
return;
396+
}
389397

390398
if (typeof(PageType) == typeof(GenericFileBrowser))
391399
{

Files UWP/GenericFileBrowser.xaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,10 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
161161
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
162162
{
163163
base.OnNavigatingFrom(e);
164-
instanceViewModel._fileQueryResult.ContentsChanged -= instanceViewModel.FileContentsChanged;
164+
if(instanceViewModel._fileQueryResult != null)
165+
{
166+
instanceViewModel._fileQueryResult.ContentsChanged -= instanceViewModel.FileContentsChanged;
167+
}
165168
}
166169

167170

Files UWP/PhotoAlbum.xaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
119119
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
120120
{
121121
base.OnNavigatingFrom(e);
122-
instanceViewModel._fileQueryResult.ContentsChanged -= instanceViewModel.FileContentsChanged;
122+
if (instanceViewModel._fileQueryResult != null)
123+
{
124+
instanceViewModel._fileQueryResult.ContentsChanged -= instanceViewModel.FileContentsChanged;
125+
}
123126
}
124127

125128
private void Clipboard_ContentChanged(object sender, object e)

0 commit comments

Comments
 (0)