Skip to content

ICustomDrawOperation object lifetime and ICustomDrawOperation.Dispose #15206

Answered by nateglasser
nateglasser asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you for the answer, yes it makes sense that the draw operations were meant to be disposed by the rendering side. I tested it just now and this is sufficient to propagate the dispose to ICustomDrawOperation:

class RenderDataCustomNode : IRenderDataItem, IDisposable
{
    public ICustomDrawOperation? Operation { get; set; }
    public bool HitTest(Point p) => Operation?.HitTest(p) ?? false;
    public void Invoke(ref RenderDataNodeRenderContext context) => Operation?.Render(new(context.Context, false));

    public Rect? Bounds => Operation?.Bounds;

    public void Dispose()
    {
        Operation?.Dispose();
        Operation = null;
    }
}

Should I submit an issue and pull request?

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@maxkatz6
Comment options

Answer selected by nateglasser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants