Properly dispose of the prototype renderer.

This commit is contained in:
Troy Stanger 2018-11-09 11:51:55 -06:00
parent fe75391962
commit 1e5561c1a8
1 changed files with 13 additions and 0 deletions

View File

@ -79,6 +79,8 @@ namespace Ooui.Forms.Renderers
if (disposing && !_disposed) {
ClearPrototype();
if (Element != null) {
var templatedItems = TemplatedItemsView.TemplatedItems;
templatedItems.CollectionChanged -= OnCollectionChanged;
@ -89,6 +91,17 @@ namespace Ooui.Forms.Renderers
}
}
void ClearPrototype()
{
if (_prototype != null)
{
var element = _prototype.Element;
element?.ClearValue(Platform.RendererProperty);
_prototype?.Dispose();
_prototype = null;
}
}
private void OnCollectionChanged (object sender, NotifyCollectionChangedEventArgs e)
{
UpdateItems ();