From c47219558e03047dd49d17eed2df4ff5031730a6 Mon Sep 17 00:00:00 2001 From: KeatonTheBot Date: Fri, 6 Mar 2026 18:13:04 -0600 Subject: [PATCH] Move SetCoreDumpable call to StorageProviderExtensions --- src/Ryujinx/Common/ApplicationHelper.cs | 15 ----- .../DownloadableContentManagerViewModel.cs | 8 --- .../UI/ViewModels/MainWindowViewModel.cs | 56 ------------------- .../UI/ViewModels/ModManagerViewModel.cs | 7 --- .../UI/ViewModels/TitleUpdateViewModel.cs | 8 --- .../UI/Views/Settings/SettingsUIView.axaml.cs | 8 --- .../UserProfileImageSelectorView.axaml.cs | 8 --- .../Utilities/StorageProviderExtensions.cs | 32 ++++++++--- 8 files changed, 23 insertions(+), 119 deletions(-) diff --git a/src/Ryujinx/Common/ApplicationHelper.cs b/src/Ryujinx/Common/ApplicationHelper.cs index f958c0159..3efd9ed62 100644 --- a/src/Ryujinx/Common/ApplicationHelper.cs +++ b/src/Ryujinx/Common/ApplicationHelper.cs @@ -18,7 +18,6 @@ using Ryujinx.Ava.UI.Windows; using Ryujinx.Ava.Utilities; using Ryujinx.Common.Helper; using Ryujinx.Common.Logging; -using Ryujinx.Common.Utilities; using Ryujinx.HLE.FileSystem; using Ryujinx.HLE.HOS.Services.Account.Acc; using Ryujinx.HLE.Loaders.Processes.Extensions; @@ -411,8 +410,6 @@ namespace Ryujinx.Ava.Common public static async Task ExtractAoc(IStorageProvider storageProvider, string updateFilePath, string updateName) { - OsUtils.SetCoreDumpable(true); - Gommon.Optional result = await storageProvider.OpenSingleFolderPickerAsync(new FolderPickerOpenOptions { Title = LocaleManager.Instance[LocaleKeys.FolderDialogExtractTitle] @@ -422,17 +419,10 @@ namespace Ryujinx.Ava.Common return; ExtractAoc(result.Value.Path.LocalPath, updateFilePath, updateName); - - if (!Program.CoreDumpArg) - { - OsUtils.SetCoreDumpable(false); - } } public static async Task ExtractSection(IStorageProvider storageProvider, NcaSectionType ncaSectionType, string titleFilePath, string titleName, int programIndex = 0) { - OsUtils.SetCoreDumpable(true); - Gommon.Optional result = await storageProvider.OpenSingleFolderPickerAsync(new FolderPickerOpenOptions { Title = LocaleManager.Instance[LocaleKeys.FolderDialogExtractTitle] @@ -442,11 +432,6 @@ namespace Ryujinx.Ava.Common return; ExtractSection(result.Value.Path.LocalPath, ncaSectionType, titleFilePath, titleName, programIndex); - - if (!Program.CoreDumpArg) - { - OsUtils.SetCoreDumpable(false); - } } public static (Result? result, bool canceled) CopyDirectory(FileSystemClient fs, string sourcePath, string destPath, CancellationToken token) diff --git a/src/Ryujinx/UI/ViewModels/DownloadableContentManagerViewModel.cs b/src/Ryujinx/UI/ViewModels/DownloadableContentManagerViewModel.cs index 0bec24945..39e53184f 100644 --- a/src/Ryujinx/UI/ViewModels/DownloadableContentManagerViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/DownloadableContentManagerViewModel.cs @@ -8,7 +8,6 @@ using Ryujinx.Ava.Common.Locale; using Ryujinx.Ava.Common.Models; using Ryujinx.Ava.Systems.AppLibrary; using Ryujinx.Ava.UI.Helpers; -using Ryujinx.Common.Utilities; using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; @@ -129,8 +128,6 @@ namespace Ryujinx.Ava.UI.ViewModels public async void Add() { - OsUtils.SetCoreDumpable(true); - IReadOnlyList result = await _storageProvider.OpenFilePickerAsync(new FilePickerOpenOptions { Title = LocaleManager.Instance[LocaleKeys.SelectDlcDialogTitle], @@ -161,11 +158,6 @@ namespace Ryujinx.Ava.UI.ViewModels { await ShowNewDlcAddedDialog(totalDlcAdded); } - - if (!Program.CoreDumpArg) - { - OsUtils.SetCoreDumpable(false); - } } private bool AddDownloadableContent(string path, out int numDlcAdded) diff --git a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs index e3d86d8a8..48e18a12e 100644 --- a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs @@ -1299,8 +1299,6 @@ namespace Ryujinx.Ava.UI.ViewModels private async Task LoadContentFromFolder(LocaleKeys localeMessageAddedKey, LocaleKeys localeMessageRemovedKey, LoadContentFromFolderDelegate onDirsSelected, LocaleKeys dirSelectDialogTitle) { - OsUtils.SetCoreDumpable(true); - Optional> result = await StorageProvider.OpenMultiFolderPickerAsync( new FolderPickerOpenOptions { Title = LocaleManager.Instance[dirSelectDialogTitle] }); @@ -1328,11 +1326,6 @@ namespace Ryujinx.Ava.UI.ViewModels (int)Symbol.Checkmark); }); } - - if (!Program.CoreDumpArg) - { - OsUtils.SetCoreDumpable(false); - } } #endregion @@ -1395,8 +1388,6 @@ namespace Ryujinx.Ava.UI.ViewModels public async Task InstallFirmwareFromFile() { - OsUtils.SetCoreDumpable(true); - Optional result = await StorageProvider.OpenSingleFilePickerAsync(new FilePickerOpenOptions { FileTypeFilter = new List @@ -1426,34 +1417,20 @@ namespace Ryujinx.Ava.UI.ViewModels { await HandleFirmwareInstallation(result.Value.Path.LocalPath); } - - if (!Program.CoreDumpArg) - { - OsUtils.SetCoreDumpable(false); - } } public async Task InstallFirmwareFromFolder() { - OsUtils.SetCoreDumpable(true); - Optional result = await StorageProvider.OpenSingleFolderPickerAsync(); if (result.HasValue) { await HandleFirmwareInstallation(result.Value.Path.LocalPath); } - - if (!Program.CoreDumpArg) - { - OsUtils.SetCoreDumpable(false); - } } public async Task InstallKeysFromFile() { - OsUtils.SetCoreDumpable(true); - Optional result = await StorageProvider.OpenSingleFilePickerAsync(new FilePickerOpenOptions { FileTypeFilter = new List @@ -1471,28 +1448,16 @@ namespace Ryujinx.Ava.UI.ViewModels { await HandleKeysInstallation(result.Value.Path.LocalPath); } - - if (!Program.CoreDumpArg) - { - OsUtils.SetCoreDumpable(false); - } } public async Task InstallKeysFromFolder() { - OsUtils.SetCoreDumpable(true); - Optional result = await StorageProvider.OpenSingleFolderPickerAsync(); if (result.HasValue) { await HandleKeysInstallation(result.Value.Path.LocalPath); } - - if (!Program.CoreDumpArg) - { - OsUtils.SetCoreDumpable(false); - } } public void OpenRyujinxFolder() @@ -1596,8 +1561,6 @@ namespace Ryujinx.Ava.UI.ViewModels public async Task OpenFile() { - OsUtils.SetCoreDumpable(true); - Optional result = await StorageProvider.OpenSingleFilePickerAsync(new FilePickerOpenOptions { Title = LocaleManager.Instance[LocaleKeys.LoadApplicationFromFileDialogTitle], @@ -1669,11 +1632,6 @@ namespace Ryujinx.Ava.UI.ViewModels LocaleManager.Instance[LocaleKeys.MenuBarFileOpenFromFileError]); } } - - if (!Program.CoreDumpArg) - { - OsUtils.SetCoreDumpable(false); - } } public async Task LoadDlcFromFolder() @@ -1696,8 +1654,6 @@ namespace Ryujinx.Ava.UI.ViewModels public async Task OpenFolder() { - OsUtils.SetCoreDumpable(true); - Optional result = await StorageProvider.OpenSingleFolderPickerAsync( new FolderPickerOpenOptions { @@ -1713,11 +1669,6 @@ namespace Ryujinx.Ava.UI.ViewModels await LoadApplication(applicationData); } - - if (!Program.CoreDumpArg) - { - OsUtils.SetCoreDumpable(false); - } } public static bool InitializeUserConfig(ApplicationData application) @@ -1925,8 +1876,6 @@ namespace Ryujinx.Ava.UI.ViewModels public async Task OpenBinFile() { - OsUtils.SetCoreDumpable(true); - if (AppHost.Device.System.SearchingForAmiibo(out _) && IsGameRunning) { Optional result = await StorageProvider.OpenSingleFilePickerAsync( @@ -1946,11 +1895,6 @@ namespace Ryujinx.Ava.UI.ViewModels { AppHost.Device.System.ScanAmiiboFromBin(result.Value.Path.LocalPath); } - - if (!Program.CoreDumpArg) - { - OsUtils.SetCoreDumpable(false); - } } } public async Task OpenSkylanderWindow() diff --git a/src/Ryujinx/UI/ViewModels/ModManagerViewModel.cs b/src/Ryujinx/UI/ViewModels/ModManagerViewModel.cs index 569d293e6..45e67add0 100644 --- a/src/Ryujinx/UI/ViewModels/ModManagerViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/ModManagerViewModel.cs @@ -288,8 +288,6 @@ namespace Ryujinx.Ava.UI.ViewModels public async void Add() { - OsUtils.SetCoreDumpable(true); - IReadOnlyList result = await _storageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions { Title = LocaleManager.Instance[LocaleKeys.SelectModDialogTitle], @@ -300,11 +298,6 @@ namespace Ryujinx.Ava.UI.ViewModels { AddMod(new DirectoryInfo(folder.Path.LocalPath)); } - - if (!Program.CoreDumpArg) - { - OsUtils.SetCoreDumpable(false); - } } public void DeleteAll() diff --git a/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs b/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs index c10da7bf9..3d34643ab 100644 --- a/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs @@ -7,7 +7,6 @@ using Ryujinx.Ava.Common.Locale; using Ryujinx.Ava.Common.Models; using Ryujinx.Ava.Systems.AppLibrary; using Ryujinx.Ava.UI.Helpers; -using Ryujinx.Common.Utilities; using System.Collections.Generic; using System.IO; using System.Linq; @@ -149,8 +148,6 @@ namespace Ryujinx.Ava.UI.ViewModels public async Task Add() { - OsUtils.SetCoreDumpable(true); - IReadOnlyList result = await _storageProvider.OpenFilePickerAsync(new FilePickerOpenOptions { AllowMultiple = true, @@ -180,11 +177,6 @@ namespace Ryujinx.Ava.UI.ViewModels { await ShowNewUpdatesAddedDialog(totalUpdatesAdded); } - - if (!Program.CoreDumpArg) - { - OsUtils.SetCoreDumpable(false); - } } public void Save() diff --git a/src/Ryujinx/UI/Views/Settings/SettingsUIView.axaml.cs b/src/Ryujinx/UI/Views/Settings/SettingsUIView.axaml.cs index 62e4e72a6..f0742a579 100644 --- a/src/Ryujinx/UI/Views/Settings/SettingsUIView.axaml.cs +++ b/src/Ryujinx/UI/Views/Settings/SettingsUIView.axaml.cs @@ -7,7 +7,6 @@ using Ryujinx.Ava.UI.Controls; using Ryujinx.Ava.UI.Helpers; using Ryujinx.Ava.UI.ViewModels; using Ryujinx.Ava.Utilities; -using Ryujinx.Common.Utilities; using System.Collections.Generic; using System.IO; using System.Linq; @@ -28,8 +27,6 @@ namespace Ryujinx.Ava.UI.Views.Settings private async Task AddDirButton(TextBox addDirBox, AvaloniaList directories) { - OsUtils.SetCoreDumpable(true); - string path = addDirBox.Text; if (!string.IsNullOrWhiteSpace(path) && Directory.Exists(path) && !directories.Contains(path)) @@ -51,11 +48,6 @@ namespace Ryujinx.Ava.UI.Views.Settings ViewModel.GameListNeedsRefresh = true; } } - - if (!Program.CoreDumpArg) - { - OsUtils.SetCoreDumpable(false); - } } private void RemoveGameDirButton_OnClick(object sender, RoutedEventArgs e) diff --git a/src/Ryujinx/UI/Views/User/UserProfileImageSelectorView.axaml.cs b/src/Ryujinx/UI/Views/User/UserProfileImageSelectorView.axaml.cs index 9b9cc3303..3a5b7c6b7 100644 --- a/src/Ryujinx/UI/Views/User/UserProfileImageSelectorView.axaml.cs +++ b/src/Ryujinx/UI/Views/User/UserProfileImageSelectorView.axaml.cs @@ -8,7 +8,6 @@ using Ryujinx.Ava.Common.Locale; using Ryujinx.Ava.UI.Controls; using Ryujinx.Ava.UI.Models; using Ryujinx.Ava.UI.ViewModels; -using Ryujinx.Common.Utilities; using Ryujinx.HLE.FileSystem; using SkiaSharp; using System.Collections.Generic; @@ -63,8 +62,6 @@ namespace Ryujinx.Ava.UI.Views.User private async void Import_OnClick(object sender, RoutedEventArgs e) { - OsUtils.SetCoreDumpable(true); - IReadOnlyList result = await ((Window)this.GetVisualRoot()!).StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions { AllowMultiple = false, @@ -84,11 +81,6 @@ namespace Ryujinx.Ava.UI.Views.User _profile.Image = ProcessProfileImage(File.ReadAllBytes(result[0].Path.LocalPath)); _parent.GoBack(); } - - if (!Program.CoreDumpArg) - { - OsUtils.SetCoreDumpable(false); - } } private void GoBack(object sender, RoutedEventArgs e) diff --git a/src/Ryujinx/Utilities/StorageProviderExtensions.cs b/src/Ryujinx/Utilities/StorageProviderExtensions.cs index 68cde0f3d..2735d4336 100644 --- a/src/Ryujinx/Utilities/StorageProviderExtensions.cs +++ b/src/Ryujinx/Utilities/StorageProviderExtensions.cs @@ -1,5 +1,7 @@ using Avalonia.Platform.Storage; using Gommon; +using Ryujinx.Common.Utilities; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -11,29 +13,42 @@ namespace Ryujinx.Ava.Utilities extension(IStorageProvider storageProvider) { public Task> OpenSingleFolderPickerAsync(FolderPickerOpenOptions openOptions = null) => - storageProvider.OpenFolderPickerAsync(FixOpenOptions(openOptions, false)) + CoreDumpable(() => storageProvider.OpenFolderPickerAsync(FixOpenOptions(openOptions, false))) .Then(folders => folders.FindFirst()); - + public Task> OpenSingleFilePickerAsync(FilePickerOpenOptions openOptions = null) => - storageProvider.OpenFilePickerAsync(FixOpenOptions(openOptions, false)) + CoreDumpable(() => storageProvider.OpenFilePickerAsync(FixOpenOptions(openOptions, false))) .Then(files => files.FindFirst()); - + public Task>> OpenMultiFolderPickerAsync(FolderPickerOpenOptions openOptions = null) => - storageProvider.OpenFolderPickerAsync(FixOpenOptions(openOptions, true)) + CoreDumpable(() => storageProvider.OpenFolderPickerAsync(FixOpenOptions(openOptions, true))) .Then(folders => folders.Count > 0 ? Optional.Of(folders) : default); - + public Task>> OpenMultiFilePickerAsync(FilePickerOpenOptions openOptions = null) => - storageProvider.OpenFilePickerAsync(FixOpenOptions(openOptions, true)) + CoreDumpable(() => storageProvider.OpenFilePickerAsync(FixOpenOptions(openOptions, true))) .Then(files => files.Count > 0 ? Optional.Of(files) : default); } + private static async Task CoreDumpable(Func> picker) + { + OsUtils.SetCoreDumpable(true); + try + { + return await picker(); + } + finally + { + if (!Program.CoreDumpArg) + OsUtils.SetCoreDumpable(false); + } + } + private static FilePickerOpenOptions FixOpenOptions(this FilePickerOpenOptions openOptions, bool allowMultiple) { if (openOptions is null) return new FilePickerOpenOptions { AllowMultiple = allowMultiple }; openOptions.AllowMultiple = allowMultiple; - return openOptions; } @@ -43,7 +58,6 @@ namespace Ryujinx.Ava.Utilities return new FolderPickerOpenOptions { AllowMultiple = allowMultiple }; openOptions.AllowMultiple = allowMultiple; - return openOptions; } }