Skip to content

Commit 55df616

Browse files
authored
Revert "[release/9.0.1xx-sr1] [Windows] Fix crash when navigating pages" (#26478) (#26549)
* Revert "[release/9.0.1xx-sr1] [release/9.0.1xx] [Windows] Fix crash when navi…" This reverts commit 51e2faf. * Update Versions.props # Conflicts: # eng/Versions.props
1 parent 73e0c98 commit 55df616

File tree

3 files changed

+6
-47
lines changed

3 files changed

+6
-47
lines changed

Diff for: eng/Versions.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<MajorVersion>9</MajorVersion>
44
<MinorVersion>0</MinorVersion>
5-
<PatchVersion>20</PatchVersion>
5+
<PatchVersion>21</PatchVersion>
66
<SdkBandVersion>9.0.100</SdkBandVersion>
77
<PreReleaseVersionLabel>servicing</PreReleaseVersionLabel>
88
<PreReleaseVersionIteration>

Diff for: src/Controls/tests/DeviceTests/Elements/Shell/ShellTests.Windows.cs

-25
Original file line numberDiff line numberDiff line change
@@ -541,31 +541,6 @@ await CreateHandlerAndAddToWindow<ShellHandler>(shell, async (handler) =>
541541
});
542542
}
543543

544-
[Fact(DisplayName = "Navigate back and forth doesn't crash")]
545-
public async Task NavigateBackAndForthDoesntCrash()
546-
{
547-
SetupBuilder();
548-
549-
var shell = await CreateShellAsync(shell =>
550-
{
551-
shell.CurrentItem = new ContentPage();
552-
});
553-
554-
await CreateHandlerAndAddToWindow<ShellHandler>(shell, async (handler) =>
555-
{
556-
var secondPage = new ContentPage();
557-
558-
for (int i = 0; i < 5; i++)
559-
{
560-
await shell.Navigation.PushAsync(secondPage, false);
561-
await Task.Delay(100);
562-
await shell.Navigation.PopToRootAsync(false);
563-
await Task.Delay(100);
564-
}
565-
Assert.NotNull(shell.Handler);
566-
});
567-
}
568-
569544
[Fact(DisplayName = "Shell Toolbar With Only MenuBarItems Is Visible")]
570545
public async Task ShellToolbarWithOnlyMenuBarItemsIsVisible()
571546
{

Diff for: src/Core/src/Platform/Windows/StackNavigationManager.cs

+5-21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
35
using System.Threading;
6+
using System.Threading.Tasks;
47
using Microsoft.UI.Xaml;
58
using Microsoft.UI.Xaml.Controls;
69
using Microsoft.UI.Xaml.Media.Animation;
@@ -14,7 +17,6 @@ public class StackNavigationManager
1417
IMauiContext _mauiContext;
1518
Frame? _navigationFrame;
1619
Action? _pendingNavigationFinished;
17-
ContentPresenter? _previousContent;
1820
bool _connected;
1921

2022
protected NavigationRootManager WindowManager => _mauiContext.GetNavigationRootManager();
@@ -56,12 +58,6 @@ public virtual void Disconnect(IStackNavigation navigationView, Frame navigation
5658
FirePendingNavigationFinished();
5759
_navigationFrame = null;
5860
NavigationView = null;
59-
60-
if (_previousContent is not null)
61-
{
62-
_previousContent.Content = null;
63-
_previousContent = null;
64-
}
6561
}
6662

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

173-
// There's some bug in our code, or the lifecycle of ContentControl, that is causing the content to
174-
// never be removed from the parent...
175-
if (_previousContent is not null)
176-
{
177-
_previousContent.Content = null;
178-
_previousContent = null;
179-
}
180-
181169
page.Content = presenter;
182170
}
183171
else
@@ -186,15 +174,13 @@ void OnNavigated(object sender, UI.Xaml.Navigation.NavigationEventArgs e)
186174
}
187175

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

193-
var platformPage = _currentPage.ToPlatform(MauiContext);
194-
195181
try
196182
{
197-
presenter.Content = platformPage;
183+
presenter.Content = _currentPage.ToPlatform(MauiContext);
198184
}
199185
catch (Exception)
200186
{
@@ -204,8 +190,6 @@ void OnNavigated(object sender, UI.Xaml.Navigation.NavigationEventArgs e)
204190

205191
_pendingNavigationFinished = () =>
206192
{
207-
_previousContent = presenter;
208-
209193
if (presenter?.Content is not FrameworkElement pc)
210194
{
211195
FireNavigationFinished();

0 commit comments

Comments
 (0)