Problems with wxMax and threading

BlitzMax Forums/Brucey's Modules/Problems with wxMax and threading

kenshin(Posted 2009) [#1]
My program runs fine when compiled in non-threaded.

So, I rebuilt all modules with thread mode enabled. Then I put:

Import "brl.threads"

at the top of the source, but I don't do anything else regarding threads. Now I find I have a crash happening which I'll explain now.

I have wxAuiManager handling five "Panes". One of those panes contains a wxAuiNotebook, and in that notebook I am creating "Pages" which hold wxHTMLWindow's. I find that if I create two of these html pages via my main menu options, and then close them manually, when I close the second one I get an unhandled exception. This is when I have a reasonable amount of html in the pages. When I have no html in the pages, then I can open and close the pages many more times, but eventually the exception will happen.

It's a bit like an overflow error, the more html data the quicker the crash. I initially thought it might be a problem with my html, but I've tried just leaving the html out and it still crashes.

Okay, so I disable threading and I don't experience this crash, enable it and I do, even though I am not creating any threads.

I tried putting this in as well,

DetachThread(MainThread())

but it didn't make any difference.

Is anybody else using threading with wxMax? Any problems with it? Is there anything special that I need to do in wxMax to make sure it's working properly with threading enabled?

I can whip up a dummy App which demonstrates this problem if required. Just wondering if anyone else has come across any similar problems with wxMax and threading before I do that?


TaskMaster(Posted 2009) [#2]
wxMax is not compatible with the BM threaded GC.


Brucey(Posted 2009) [#3]
There are issues with the new garbage collector. It's possible that because the pre-compiled wxWidgets libraries are not using its allocators, things become confused and maybe some of the Blitz-created objects are being GC'd prematurely - on the assumption that the garbage collector doesn't realise that the objects are still in use by wxWidgets...

I'm not sure of a best way forward with this. One option might be to attempt to build wxWidgets using the new GC - but that seems like a massive undertaking, which may not even work....

Maybe there is a quick-fix for it, but I have as yet to work out what exactly is causing the crashes.


kenshin(Posted 2009) [#4]
Ok. Thanks for clearing it up. Don't panic though. Although it would be nice, I don't absolutely need threading to work with wxMax. I can work around it.

Thx for saving me from ripping my program apart again:)


Brucey(Posted 2009) [#5]
On a brighter note, wxMax should work fine with Mark's new threaded GC in the latest BlitzMax :-)

Although you should be aware about limitations of updating widgets outside of the main thread.