Skip to content

Commit

Permalink
Revert "[release/9.0.1xx-sr1] [Windows] Fix crash when navigating pag…
Browse files Browse the repository at this point in the history
…es" (#26478)

* Revert "[release/9.0.1xx-sr1] [release/9.0.1xx] [Windows] Fix crash when navi…"

This reverts commit 51e2faf.

* Update Versions.props
  • Loading branch information
PureWeen authored Dec 9, 2024
1 parent e4703fb commit 85f2a06
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 48 deletions.
4 changes: 2 additions & 2 deletions eng/Versions.props
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project>
<PropertyGroup>
<!-- The .NET product branding version -->
<ProductVersion>9.0.13</ProductVersion>
<ProductVersion>9.0.14</ProductVersion>
<MajorVersion>9</MajorVersion>
<MinorVersion>0</MinorVersion>
<PatchVersion>13</PatchVersion>
<PatchVersion>14</PatchVersion>
<SdkBandVersion>9.0.100</SdkBandVersion>
<PreReleaseVersionLabel>servicing</PreReleaseVersionLabel>
<PreReleaseVersionIteration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,31 +541,6 @@ await CreateHandlerAndAddToWindow<ShellHandler>(shell, async (handler) =>
});
}

[Fact(DisplayName = "Navigate back and forth doesn't crash")]
public async Task NavigateBackAndForthDoesntCrash()
{
SetupBuilder();

var shell = await CreateShellAsync(shell =>
{
shell.CurrentItem = new ContentPage();
});

await CreateHandlerAndAddToWindow<ShellHandler>(shell, async (handler) =>
{
var secondPage = new ContentPage();

for (int i = 0; i < 5; i++)
{
await shell.Navigation.PushAsync(secondPage, false);
await Task.Delay(100);
await shell.Navigation.PopToRootAsync(false);
await Task.Delay(100);
}
Assert.NotNull(shell.Handler);
});
}

[Fact(DisplayName = "Shell Toolbar With Only MenuBarItems Is Visible")]
public async Task ShellToolbarWithOnlyMenuBarItemsIsVisible()
{
Expand Down
26 changes: 5 additions & 21 deletions src/Core/src/Platform/Windows/StackNavigationManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media.Animation;
Expand All @@ -14,7 +17,6 @@ public class StackNavigationManager
IMauiContext _mauiContext;
Frame? _navigationFrame;
Action? _pendingNavigationFinished;
ContentPresenter? _previousContent;
bool _connected;

protected NavigationRootManager WindowManager => _mauiContext.GetNavigationRootManager();
Expand Down Expand Up @@ -56,12 +58,6 @@ public virtual void Disconnect(IStackNavigation navigationView, Frame navigation
FirePendingNavigationFinished();
_navigationFrame = null;
NavigationView = null;

if (_previousContent is not null)
{
_previousContent.Content = null;
_previousContent = null;
}
}

public virtual void NavigateTo(NavigationRequest args)
Expand Down Expand Up @@ -170,14 +166,6 @@ void OnNavigated(object sender, UI.Xaml.Navigation.NavigationEventArgs e)
VerticalAlignment = UI.Xaml.VerticalAlignment.Stretch
};

// There's some bug in our code, or the lifecycle of ContentControl, that is causing the content to
// never be removed from the parent...
if (_previousContent is not null)
{
_previousContent.Content = null;
_previousContent = null;
}

page.Content = presenter;
}
else
Expand All @@ -186,15 +174,13 @@ void OnNavigated(object sender, UI.Xaml.Navigation.NavigationEventArgs e)
}

// At this point if the Content isn't a ContentPresenter the user has replaced
// the content so we just let them take control
// the conent so we just let them take control
if (presenter == null || _currentPage == null)
return;

var platformPage = _currentPage.ToPlatform(MauiContext);

try
{
presenter.Content = platformPage;
presenter.Content = _currentPage.ToPlatform(MauiContext);
}
catch (Exception)
{
Expand All @@ -204,8 +190,6 @@ void OnNavigated(object sender, UI.Xaml.Navigation.NavigationEventArgs e)

_pendingNavigationFinished = () =>
{
_previousContent = presenter;

if (presenter?.Content is not FrameworkElement pc)
{
FireNavigationFinished();
Expand Down

0 comments on commit 85f2a06

Please sign in to comment.