Sfoglia il codice sorgente

Fixed memory leak in flood fill

Krzysztof Krysiński 1 mese fa
parent
commit
e6ba99d9e5

+ 2 - 1
src/PixiEditor.ChangeableDocument/Changes/Drawing/FloodFill/FloodFillHelper.cs

@@ -53,7 +53,7 @@ public static class FloodFillHelper
 
 
         int chunkSize = ChunkResolution.Full.PixelSize();
         int chunkSize = ChunkResolution.Full.PixelSize();
 
 
-        FloodFillChunkCache cache = CreateCache(membersToFloodFill, document, frame);
+        using FloodFillChunkCache cache = CreateCache(membersToFloodFill, document, frame);
 
 
         VecI initChunkPos = OperationHelper.GetChunkPos(startingPos, chunkSize);
         VecI initChunkPos = OperationHelper.GetChunkPos(startingPos, chunkSize);
         VecI imageSizeInChunks = (VecI)(document.Size / (double)chunkSize).Ceiling();
         VecI imageSizeInChunks = (VecI)(document.Size / (double)chunkSize).Ceiling();
@@ -111,6 +111,7 @@ public static class FloodFillHelper
             {
             {
                 var chunk = Chunk.Create(document.ProcessingColorSpace);
                 var chunk = Chunk.Create(document.ProcessingColorSpace);
                 chunk.Surface.DrawingSurface.Canvas.Clear(Colors.Transparent);
                 chunk.Surface.DrawingSurface.Canvas.Clear(Colors.Transparent);
+
                 drawingChunks[chunkPos] = chunk;
                 drawingChunks[chunkPos] = chunk;
             }
             }
 
 

+ 5 - 0
src/PixiEditor.ChangeableDocument/Rendering/DocumentRenderer.cs

@@ -84,6 +84,11 @@ public class DocumentRenderer : IPreviewRenderable, IDisposable
         {
         {
             renderTexture.DrawingSurface.Canvas.Restore();
             renderTexture.DrawingSurface.Canvas.Restore();
             toRenderOn.Canvas.Restore();
             toRenderOn.Canvas.Restore();
+            if (membersOnlyGraph is IDisposable disposableGraph)
+            {
+                disposableGraph.Dispose();
+            }
+
             IsBusy = false;
             IsBusy = false;
         }
         }
     }
     }