Browse Source

Fix crash related to chunk pooling

Equbuxu 2 years ago
parent
commit
58f15012b6
2 changed files with 4 additions and 10 deletions
  1. 4 5
      src/ChunkyImageLib/Chunk.cs
  2. 0 5
      src/ChunkyImageLib/ChunkyImage.cs

+ 4 - 5
src/ChunkyImageLib/Chunk.cs

@@ -8,7 +8,7 @@ namespace ChunkyImageLib;
 public class Chunk : IDisposable
 {
     private static volatile int chunkCounter = 0;
-    
+
     /// <summary>
     /// The number of chunks that haven't yet been returned (includes garbage collected chunks).
     /// Used in tests to make sure that all chunks are disposed.
@@ -16,17 +16,17 @@ public class Chunk : IDisposable
     public static int ChunkCounter => chunkCounter;
 
     private bool returned = false;
-    
+
     /// <summary>
     /// The surface of the chunk
     /// </summary>
     public Surface Surface { get; }
-    
+
     /// <summary>
     /// The size of the chunk
     /// </summary>
     public VecI PixelSize { get; }
-    
+
     /// <summary>
     /// The resolution of the chunk
     /// </summary>
@@ -68,7 +68,6 @@ public class Chunk : IDisposable
     {
         if (returned)
             return;
-        Surface.DrawingSurface.Canvas.Flush();
         returned = true;
         Interlocked.Decrement(ref chunkCounter);
         ChunkPool.Instance.Push(this);

+ 0 - 5
src/ChunkyImageLib/ChunkyImage.cs

@@ -1204,9 +1204,4 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
 
         disposed = true;
     }
-
-    ~ChunkyImage()
-    {
-        DisposeAll();
-    }
 }