Skip to content

Commit

Permalink
making sure native render and native element will be disposed (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-dorri89 authored Sep 3, 2024
1 parent ddc2202 commit e4c9a8c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Core/Native/Renderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ internal interface IRenderOrchestrator : IDisposable { Task<BaseNativeType> Rend

public partial class Renderer : IDisposable
{
INativeRenderer NativeRenderer;
public View View { get; private set; }
public Renderer(View view) => View = view;
IRenderOrchestrator RenderOrchestrator;
Expand All @@ -35,9 +36,9 @@ internal BaseNativeType CreateFromNativeRenderer()

rendererType = rendererType.GenericTypeArguments.Single();

var renderer = (INativeRenderer)rendererType.CreateInstance();
NativeRenderer = (INativeRenderer)rendererType.CreateInstance();

return renderer.Render(this).GetAlreadyCompletedResult();
return NativeRenderer.Render(this).GetAlreadyCompletedResult();
}

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions Zebble/UWP/Renderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ public void Dispose()
NativeContainer = null;
View = null;

NativeRenderer?.Dispose();
(NativeElement as IDisposable)?.Dispose();
NativeRenderer = null;
NativeElement = null;

GC.SuppressFinalize(this);
Expand Down

0 comments on commit e4c9a8c

Please sign in to comment.