Skip to content

Commit

Permalink
Dispose Homepage on navigation (#4472)
Browse files Browse the repository at this point in the history
  • Loading branch information
d2dyno1 authored May 14, 2021
1 parent f76b8c1 commit a23aa99
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions Files/Views/ColumnShellPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Files.Common;
using Files.Dialogs;
using Files.EventArguments;
using Files.Extensions;
using Files.Filesystem;
using Files.Filesystem.FilesystemHistory;
using Files.Filesystem.Search;
Expand Down
1 change: 1 addition & 0 deletions Files/Views/ModernShellPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Files.DataModels;
using Files.Dialogs;
using Files.EventArguments;
using Files.Extensions;
using Files.Filesystem;
using Files.Filesystem.FilesystemHistory;
using Files.Filesystem.Search;
Expand Down
13 changes: 8 additions & 5 deletions Files/Views/WidgetsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ namespace Files.Views
public sealed partial class WidgetsPage : Page, IDisposable
{
private IShellPage AppInstance = null;
public SettingsViewModel AppSettings => App.AppSettings;
public FolderSettingsViewModel FolderSettings => AppInstance?.InstanceViewModel.FolderSettings;
public NamedPipeAsAppServiceConnection Connection => AppInstance?.ServiceConnection;

private LibraryCards libraryCards;
private DrivesWidget drivesWidget;
Expand All @@ -42,6 +40,13 @@ public WidgetsPage()
Widgets.ViewModel.WidgetListRefreshRequestedInvoked += ViewModel_WidgetListRefreshRequestedInvoked;
}

protected override void OnNavigatedFrom(NavigationEventArgs e)
{
this.Dispose();

base.OnNavigatedFrom(e);
}

public void RefreshWidgetList() => Widgets.ViewModel.RefreshWidgetList();

private void ViewModel_WidgetListRefreshRequestedInvoked(object sender, EventArgs e)
Expand Down Expand Up @@ -135,7 +140,7 @@ private async void RecentFilesWidget_RecentFileInvoked(object sender, UserContro
}
else
{
foreach (DriveItem drive in Enumerable.Concat(App.DrivesManager.Drives, AppSettings.CloudDrivesManager.Drives))
foreach (DriveItem drive in Enumerable.Concat(App.DrivesManager.Drives, App.AppSettings.CloudDrivesManager.Drives))
{
if (drive.Path.ToString() == new DirectoryInfo(e.ItemPath).Root.ToString())
{
Expand Down Expand Up @@ -236,8 +241,6 @@ protected override async void OnNavigatedTo(NavigationEventArgs eventArgs)

#region IDisposable

// TODO: This Dispose() is never called, please implement the functionality to call this function.
// This IDisposable.Dispose() needs to be called to unhook events in BundlesWidget to avoid memory leaks.
public void Dispose()
{
ViewModel.YourHomeLoadedInvoked -= ViewModel_YourHomeLoadedInvoked;
Expand Down

0 comments on commit a23aa99

Please sign in to comment.