Skip to content

Commit

Permalink
Merge pull request #5656 from peppy/fix-ios-crash-directory-selector
Browse files Browse the repository at this point in the history
Fix potential crash when displaying `DirectorySelector` on AOT platforms
  • Loading branch information
smoogipoo authored Feb 21, 2023
2 parents 617c03e + 1078ad4 commit 2924ead
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions osu.Framework/Graphics/UserInterface/DirectorySelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ private void updateDisplay()
{
directoryChanging = true;

directoryFlow.Clear();

var newDirectory = CurrentPath.Value;
bool notifyError = false;
ICollection<DirectorySelectorItem> items = Array.Empty<DirectorySelectorItem>();
Expand All @@ -160,16 +158,27 @@ private void updateDisplay()

if (newDirectory == null)
{
var drives = DriveInfo.GetDrives();
try
{
// This will throw on AOT platforms (System.ExecutionEngineException: Attempting to JIT compile method).
var drives = DriveInfo.GetDrives();

directoryFlow.Clear();

foreach (var drive in drives)
directoryFlow.Add(CreateDirectoryItem(drive.RootDirectory));
foreach (var drive in drives)
directoryFlow.Add(CreateDirectoryItem(drive.RootDirectory));
}
catch
{
NotifySelectionError();
}

return;
}

CurrentPath.Value = newDirectory;

directoryFlow.Clear();
directoryFlow.Add(CreateParentDirectoryItem(newDirectory.Parent));
directoryFlow.AddRange(items);
}
Expand Down

0 comments on commit 2924ead

Please sign in to comment.