As the title says, I sometimes (not consistently) get a AccessViolationException when attempting to use .GetGlobalBounds() on an SFML text object from within my drawing loop.
I do not know how to reproduce this, and it happens randomly when I start my program. I have tried limiting my application to only using one thread for both drawing and updating as opposed to two or three threads but it did not help. Initializing the font object from a byte array before using it in the constructor of a text object reduced the issue, but did not resolve it, please help!
Stacktrace: at SFML.Graphics.Text.sfText_getLocalBounds(IntPtr CPointer)
at SFML.Graphics.Text.GetLocalBounds()
at GameLibrary.Game.Graphics.Text.get_Bounds() in C:\Users\username\Documents\Repositories\GameLibrary\Solution\Libraries\GameLibrary.Game\Graphics\Shapes\Text.cs:line 203
at ProjectName.Gui.Label.get_LocalBounds() in C:\Users\username\Documents\GitHub\ProjectName\ProjectName\Code\Gui\Label.cs:line 15
at ProjectName.Gui.Toolbar.<>c.<Autoposition>b__52_0(ToolbarButton child) in C:\Users\username\Documents\GitHub\ProjectName\ProjectName\Code\Gui\Toolbar.cs:line 249
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Linq.Enumerable.Max(IEnumerable`1 source)
at System.Linq.Enumerable.Max[TSource](IEnumerable`1 source, Func`2 selector)
at ProjectName.Gui.Toolbar.Autoposition(IRenderTarget target) in C:\Users\username\Documents\GitHub\ProjectName\ProjectName\Code\Gui\Toolbar.cs:line 249
at ProjectName.Gui.Toolbar.Draw(IRenderTarget target, RenderStates states) in C:\Users\username\Documents\GitHub\ProjectName\ProjectName\Code\Gui\Toolbar.cs:line 299
at ProjectName.States.SimulationState.Draw(IRenderTarget target, RenderStates states) in C:\Users\username\Documents\GitHub\ProjectName\ProjectName\Code\States\SimulationState.cs:line 94
at GameLibrary.Game.States.StateEngine.Draw(IRenderTarget target, RenderStates states) in C:\Users\username\Documents\Repositories\GameLibrary\Solution\Libraries\GameLibrary.Game\States\StateEngine.cs:line 106
at GameLibrary.Game.Game.Draw(IDrawable drawable) in C:\Users\username\Documents\Repositories\GameLibrary\Solution\Libraries\GameLibrary.Game\Game.cs:line 802
at GameLibrary.Game.Game.OnDraw() in C:\Users\username\Documents\Repositories\GameLibrary\Solution\Libraries\GameLibrary.Game\Game.cs:line 654
at ProjectName.Simulation.OnDraw() in C:\Users\username\Documents\GitHub\ProjectName\ProjectName\Code\Simulation.cs:line 358
at GameLibrary.Game.Game.EmbeddedDraw() in C:\Users\username\Documents\Repositories\GameLibrary\Solution\Libraries\GameLibrary.Game\Game.cs:line 609
at ProjectName.Program.Main(String[] args) in C:\Users\username\Documents\GitHub\ProjectName\ProjectName\Program.cs:line 299