From 0d092133e2c8d9e64ccf56123778ee372d14dfcd Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Thu, 3 Oct 2019 17:20:07 -0600 Subject: [PATCH] Remove Material Frame Renderer from Frame element on dispose of renderer (#7752) fixes #7339 * [iOS] remove renderer from Frame on dispose * - add uitests --- .../Issue7339.cs | 58 +++++++++++++++++++ ...rin.Forms.Controls.Issues.Shared.projitems | 2 + .../MaterialFrameRenderer.cs | 8 ++- 3 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7339.cs diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7339.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7339.cs new file mode 100644 index 000000000..5020601ad --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7339.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Text; +using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.Internals; + + +#if UITEST +using Xamarin.UITest; +using NUnit.Framework; +using Xamarin.Forms.Core.UITests; +#endif + +namespace Xamarin.Forms.Controls.Issues +{ + [Preserve(AllMembers = true)] + [Issue(IssueTracker.Github, 7339, "[iOS] Material frame renderer not being cleared", + PlatformAffected.iOS)] +#if UITEST + [NUnit.Framework.Category(UITestCategories.Shell)] +#endif + public class Issue7339 : TestShell + { + protected override void Init() + { + Visual = VisualMarker.Material; + CreateContentPage("Item1").Content = + new StackLayout() + { + Children = + { + new Frame() + { + Content = new Label() + { + Text = "Navigate between flyout items a few times. If app doesn't crash then test has passed" + } + } + } + }; + + CreateContentPage("Item2").Content = + new StackLayout() { Children = { new Frame() } }; + } + +#if UITEST + [Test] + public void MaterialFrameDisposesCorrectly() + { + TapInFlyout("Item1"); + TapInFlyout("Item2"); + TapInFlyout("Item1"); + TapInFlyout("Item2"); + } +#endif + } +} diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index 5da64217c..95974a684 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -28,6 +28,7 @@ + @@ -58,6 +59,7 @@ + diff --git a/Xamarin.Forms.Material.iOS/MaterialFrameRenderer.cs b/Xamarin.Forms.Material.iOS/MaterialFrameRenderer.cs index 75ae3ffd6..ba78e831f 100644 --- a/Xamarin.Forms.Material.iOS/MaterialFrameRenderer.cs +++ b/Xamarin.Forms.Material.iOS/MaterialFrameRenderer.cs @@ -100,13 +100,17 @@ namespace Xamarin.Forms.Material.iOS if (_packager == null) return; - SetElement(null); - _packager.Dispose(); _packager = null; _tracker.Dispose(); _tracker = null; + + if (Element != null) + { + Element.ClearValue(Platform.iOS.Platform.RendererProperty); + SetElement(null); + } } base.Dispose(disposing);