summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.iOS
diff options
context:
space:
mode:
authorSamantha Houts <samhouts@users.noreply.github.com>2017-05-02 23:18:05 (GMT)
committerGitHub <noreply@github.com>2017-05-02 23:18:05 (GMT)
commit20bfa5b5038ef3357f6048b1cb13105033650069 (patch)
treefaeb9d60c2eeac5682fcb60e2751f20f6c09006c /Xamarin.Forms.Platform.iOS
parent8af6f3eb5c94e5d240fd93611ef18a7fa94f27d2 (diff)
downloadxamarin-forms-20bfa5b5038ef3357f6048b1cb13105033650069.zip
xamarin-forms-20bfa5b5038ef3357f6048b1cb13105033650069.tar.gz
xamarin-forms-20bfa5b5038ef3357f6048b1cb13105033650069.tar.bz2
[iOS] Null Element before disposing trial renderers in uneven ListViews (#894)
* Add repro for 55745 * [iOS] Null Element before disposing trial renderers
Diffstat (limited to 'Xamarin.Forms.Platform.iOS')
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs12
-rw-r--r--Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs10
2 files changed, 18 insertions, 4 deletions
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs
index d060e7f..3c5bcb1 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs
@@ -690,8 +690,18 @@ namespace Xamarin.Forms.Platform.iOS
foreach (Element descendant in target.Descendants())
{
IVisualElementRenderer renderer = Platform.GetRenderer(descendant as VisualElement);
+
+ // Clear renderer from descendent; this will not happen in Dispose as normal because we need to
+ // unhook the Element from the renderer before disposing it.
descendant.ClearValue(Platform.RendererProperty);
- renderer?.Dispose();
+
+ if (renderer != null)
+ {
+ // Unhook Element (descendant) from renderer before Disposing so we don't set the Element to null
+ renderer.SetElement(null);
+ renderer.Dispose();
+ renderer = null;
+ }
}
return (nfloat)req.Request.Height;
diff --git a/Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs b/Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs
index 3fcb3ff..d63385d 100644
--- a/Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs
@@ -251,9 +251,13 @@ namespace Xamarin.Forms.Platform.MacOS
_packager = null;
}
- Platform.SetRenderer(Element, null);
- SetElement(null);
- Element = null;
+ // The ListView can create renderers and unhook them from the Element before Dispose is called.
+ // Thus, it is possible that this work is already completed.
+ if (Element != null)
+ {
+ Platform.SetRenderer(Element, null);
+ SetElement(null);
+ }
}
base.Dispose(disposing);
}