Browse Source

Dispose checks

flabbet 1 year ago
parent
commit
018c568975

+ 1 - 1
src/PixiEditor.AvaloniaUI/Models/Rendering/MemberPreviewUpdater.cs

@@ -688,7 +688,7 @@ internal class MemberPreviewUpdater
         // TODO: recreate only changed previews
         internals.Tracker.Document.NodeGraph.TryTraverse(node =>
         {
-            if (node.CachedResult != null)
+            if (node.CachedResult is { IsDisposed: false })
             {
                var nodeVm = doc.StructureHelper.FindNode<INodeHandler>(node.Id);
 

+ 1 - 1
src/PixiEditor.ChangeableDocument/Changeables/Document.cs

@@ -100,7 +100,7 @@ internal class Document : IChangeable, IReadOnlyDocument, IDisposable
         }
         else
         {
-            image = layer.Execute(new RenderingContext(frame));
+            image = new Surface(layer.Execute(new RenderingContext(frame)));
         }
         
         //todo: idk if it's correct

+ 1 - 1
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/ImageLayerNode.cs

@@ -76,7 +76,7 @@ public class ImageLayerNode : LayerNode, IReadOnlyImageNode
             workingSurface = Background.Value;
             blendPaint.BlendMode = RenderingContext.GetDrawingBlendMode(BlendMode.Value);
         }
-        else if (!hasSurface || workingSurface.Size != targetSize)
+        else if (!hasSurface || workingSurface.Size != targetSize || workingSurface.IsDisposed)
         {
             workingSurfaces[targetResolution] = new Surface(targetSize);
             workingSurface = workingSurfaces[targetResolution];

+ 0 - 1
src/PixiEditor.ChangeableDocument/Rendering/DocumentEvaluator.cs

@@ -37,7 +37,6 @@ public static class DocumentEvaluator
             int height = (int)(ChunkyImage.FullChunkSize * resolution.Multiplier());
             
             RectD sourceRect = new(x, y, width, height);
-            RectD destRect = new(0, 0, chunk.PixelSize.X, chunk.PixelSize.Y);
 
             using var chunkSnapshot = evaluated.DrawingSurface.Snapshot((RectI)sourceRect);