multiple canvas crash randomly? maxgui directx dx

BlitzMax Forums/MaxGUI Module/multiple canvas crash randomly? maxgui directx dx

skn3(Posted 2012) [#1]
Hey this is really just a post so if anyone comes looking in the future.

I have been writing an application for months and until yesterday had not experienced issues with the directx drivers when dealing with multiple canvases. All of a sudden a dialogue that uses and then throws away a canvas was deciding it wanted to crash with EXCEPTION_ACCESS_VIOLATION. This has not happened before with a different dialogue that did the same so I couldn't explain why it was happening now.

I looked into many forum threads and people talked about maxgui destroying the entire directx context when a canvas is freed. This fitted as I debugged the brl dx7 driver and the device was null!

It turns out I was forgetting to free a custom gadget that contained a canvas and then then something weird was happening under the hood. Maybe the garbage collector? Maybe a timer tick too late that was attempting to paint to the canvas? Whatever was happening to crash was down to the fact that the nested canvas had not been properly freed upon closing the dialogue!

So to anyone who finds this post, try enforcing that all your canvas are freed by hand and then see if that fixes your problems. It did for me!