1
DotNet / System.AccessViolation
« on: July 16, 2013, 11:39:50 am »
After creating a RenderWindow and rendering lots of pretty things, i randomly had this piece of code throwing AccessViolations from the Text constructor.
The font is a static loaded resource, but to make sure, I've tested that the constructor doesn't misbehave if I pass null or a disposed Font, so this is not the issue.
I'm wondering if you could share any insight into the things that could be causing this behavior, so i know what to look for.
public int GetTextWidthPixels(string text, Font font, uint fontSize)
{
var textShape = new Text(text, font, fontSize);
var bounds = textShape.FindCharacterPos((uint)(text.Length));
textShape.Dispose();
return (int)bounds.X;
}
{
var textShape = new Text(text, font, fontSize);
var bounds = textShape.FindCharacterPos((uint)(text.Length));
textShape.Dispose();
return (int)bounds.X;
}
The font is a static loaded resource, but to make sure, I've tested that the constructor doesn't misbehave if I pass null or a disposed Font, so this is not the issue.
I'm wondering if you could share any insight into the things that could be causing this behavior, so i know what to look for.