SkiaSharp
SkiaSharp copied to clipboard
It is necessary to check whether an object is disposed before using it.
Is your feature request related to a problem?
I was careless to call dispose on the SKPaint object before passing it to the function as an argument. After that, my program crashed with the text in the console "segmentation error" without a stack trace or a detailed description.
This error does not happen in this code:
font.MeasureText(line, paint);
But this error happens in this code: canvas.DrawText(text, x, y, font, paint);
Describe the solution you would like
It would be good if your library checked whether the object was disposed of before using it, and if it was disposed of, then it would also throw an exception with the text "object SKPaint has already been disposed, cannot be used". Because I spent the whole day understanding why it happens.
Describe alternatives you have considered
No thought
Additional context
No response
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Hmm, yeah. Good idea. I wonder how many issues will be found.
We could check when we get the handle. So we can pass the objects around, but then an exception just before it goes into native code.
This will save us from having to check objects on every line of code.