This is how I'm currently doing :
My Thread run function:
/* virtual */ void ZePurpleApi::run()
{
// Starting event loop
exec();
}
/* virtual */ void ZePurpleApi::run()
{
// Starting event loop
exec();
}
To copy to clipboard, switch view to plain text mode
The slot I'm calling right after thread->start:
void ZePurpleApi::onThreadStart()
{
// We are in the good thread here
g_print("ZePurpleApi - onThreadStart %d\n", currentThreadId());
InitPurpleApi();
GMainLoop *loop = g_main_loop_new(NULL, FALSE);
// Unfortunately the g_main_loop appears to block the Qt event loop
g_main_loop_run(loop);
}
void ZePurpleApi::onThreadStart()
{
// We are in the good thread here
g_print("ZePurpleApi - onThreadStart %d\n", currentThreadId());
InitPurpleApi();
GMainLoop *loop = g_main_loop_new(NULL, FALSE);
// Unfortunately the g_main_loop appears to block the Qt event loop
g_main_loop_run(loop);
}
To copy to clipboard, switch view to plain text mode
I think I cannot adopt your approach sincie I need my init Before the g_main_loop_run(loop); and after the exec(); otherwise my lib signals aren't propagated correctly in the proper thread.
Anybody has an idea?
Bookmarks