how to separating g_main_loop from qt gui thread
-
wrote on 13 Jul 2020, 01:44 last edited by
how to separating g_main_loop from qt gui thread.
I executed g_main_loop in a separate Thread as below.
However, signal events in GLib(dbus) are always received as GUI Main Thread.please tell me.. How do I separate g_main_loop from qt gui thread?
void HmiAppInit() { ... m_mainLoopThread = std::thread([&]() { m_mainLoop = g_main_loop_new(nullptr, FALSE); g_main_loop_run(m_mainLoop); }); ... } int main(int argc, char **argv) { QGuiApplication app(argc, argv); HmiAppInit(); return app.exec(); }
-
Hi,
Can you explain why you want to use the GLib loop ?
-
wrote on 14 Jul 2020, 02:09 last edited by sootoo23
Hi ,
thank you for your reply.
I use GDBus for communication between different apps.
(GDBus handles signal events in g_main_loop.)However, if there are many touch and dbus events in the GUI Thread, it will hang.
Also, "The Wayland connection broke. Did the Wayland compositor die?" is printed and the app is terminated.
Therefore, I try to process GUIThread and GDBus events with different Threads. -
Since you are using Qt, why not use the QtDBus module ?
-
how to separating g_main_loop from qt gui thread.
I executed g_main_loop in a separate Thread as below.
However, signal events in GLib(dbus) are always received as GUI Main Thread.please tell me.. How do I separate g_main_loop from qt gui thread?
void HmiAppInit() { ... m_mainLoopThread = std::thread([&]() { m_mainLoop = g_main_loop_new(nullptr, FALSE); g_main_loop_run(m_mainLoop); }); ... } int main(int argc, char **argv) { QGuiApplication app(argc, argv); HmiAppInit(); return app.exec(); }
This post is deleted! -
Qt being asynchronous, why do you need to handle the DBus messages in another thread ?
-
wrote on 16 Jul 2020, 02:44 last edited by
@SGaist
if there are many touch and dbus events in the GUI Thread, it will delays or hangs.
Also, "The Wayland connection broke. Did the Wayland compositor die?" is printed and the app is terminated.
Therefore, I try to process GUIThread and GDBus events with different Threads. -
Did you benchmark QtDBus with your GUI to see if you have that issue ?
2/9