Skip to content

Commit

Permalink
fix: fixed possible memory leak code (#1190)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuto-trd authored Dec 5, 2024
1 parent 2108b57 commit 4723392
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Beutl.Engine/Graphics/Rendering/RenderLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void AcceptsAll(IGraphicNode node)
supportCache.Accepts(cache);
if (cache.IsCached
&& !(cache.CanCacheBoundary()
&& cacheContext.CanCacheRecursiveChildrenOnly(node)))
&& cacheContext.CanCacheRecursiveChildrenOnly(node)))
{
cache.Invalidate();
}
Expand Down Expand Up @@ -171,7 +171,15 @@ public void Dispose()
}

_cache.Clear();
_currentFrame?.Clear();
if (_currentFrame != null)
{
foreach (Entry item in _currentFrame)
{
item.Dispose();
}

_currentFrame.Clear();
}
}

public Drawable? HitTest(Point point)
Expand Down
1 change: 1 addition & 0 deletions src/Beutl.Engine/Graphics/Rendering/Renderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public void Dispose()
OnDispose(true);
_immediateCanvas.Dispose();
_cacheContext.Dispose();
RenderScene.Dispose();
GC.SuppressFinalize(this);

IsDisposed = true;
Expand Down
1 change: 1 addition & 0 deletions src/Beutl/ViewModels/PlayerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ public void Dispose()
AfterRendered.Dispose();
PreviewInvalidated = null;
Scene = null!;
PreviewImage.Value = null!;
_logger.LogInformation("Disposed PlayerViewModel. ({SceneId})", _editViewModel.SceneId);
}

Expand Down

0 comments on commit 4723392

Please sign in to comment.