Hi everyone,
I read all the posts for this problem here, but I cannot solve my problem.
The thing is that I am making a SDK - I don't have a main thread to perform GUI events with PostEvent.
In one of the functions I pop up wxDialog and I show images from real time camera.
So wxWidets is used at this function only and it is running in one of the threads that I have.
Before I create the dialog I create IMPLEMENT_APP_NO_MAIN wxApp and than I use wxMutexGuiEnter/wxMutexGuiLeave to perform GUI relates stuff.
On Windows with MinGW this works perfectly fine.
But now I need to port the code to Linux with GTK+ and I get deadlock when wxMutexGuiEnter/wxMutexGuiLeave is used. I am not able to get the dialog running from another thread.
I also did experiments - main thread with wxApp- IMPLEMENT_APP and wxMutexGuiEnter/wxMutexGuiLeave works fine on Linux with GTK.
So it looks to me that wxMutexGuiEnter/wxMutexGuiLeave goes in deadlock only when the main thread is not wxWigdets related.
I am aware that this is not wxWigets specific but I need to find solution.
Any suggestions will be greatly appreciated.
Thanks
GUI update from another thread
Thanks for the reply.megabyte wrote:I don't see any problem to use threads in a library which has no main thread. The library is used in an application which has a main thread and a messages loop.
I don't have problem using the threads, I have problem to do GUI related stuff from the thread.
This is a SDK so the application which has a main thread and a message loop is not in my hands.
When this function is called another thread is created, in which I have to show this dialog, show some real time images taken from camera and close it at the end of the function.
I would like to quote this from the documentationBut now I need to port the code to Linux with GTK+ and I get deadlock when wxMutexGuiEnter/wxMutexGuiLeave is used. I am not able to get the dialog running from another thread.
I am not sure whether this would be helpful to you...void ::wxMutexGuiEnter()
....
...
Note that under GTK, no creation of top-level windows is allowed in any thread but the main one.
This function is only defined on platforms which support preemptive threads.