Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. how to separating g_main_loop from qt gui thread
Forum Updated to NodeBB v4.3 + New Features

how to separating g_main_loop from qt gui thread

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
9 Posts 3 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sootoo23
    wrote on 13 Jul 2020, 01:44 last edited by
    #1

    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();
    }
    
    J 1 Reply Last reply 15 Jul 2020, 06:29
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 13 Jul 2020, 19:30 last edited by
      #2

      Hi,

      Can you explain why you want to use the GLib loop ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply 14 Jul 2020, 02:09
      0
      • S SGaist
        13 Jul 2020, 19:30

        Hi,

        Can you explain why you want to use the GLib loop ?

        S Offline
        S Offline
        sootoo23
        wrote on 14 Jul 2020, 02:09 last edited by sootoo23
        #3

        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.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 14 Jul 2020, 19:14 last edited by
          #4

          Since you are using Qt, why not use the QtDBus module ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          S 1 Reply Last reply 15 Jul 2020, 01:13
          0
          • S SGaist
            14 Jul 2020, 19:14

            Since you are using Qt, why not use the QtDBus module ?

            S Offline
            S Offline
            sootoo23
            wrote on 15 Jul 2020, 01:13 last edited by
            #5

            @SGaist
            If I use QDbus, can I separate DBus event from GUI event Thread?

            1 Reply Last reply
            0
            • S sootoo23
              13 Jul 2020, 01:44

              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();
              }
              
              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 15 Jul 2020, 06:29 last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 15 Jul 2020, 18:03 last edited by
                #7

                Qt being asynchronous, why do you need to handle the DBus messages in another thread ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                S 1 Reply Last reply 16 Jul 2020, 02:44
                1
                • S SGaist
                  15 Jul 2020, 18:03

                  Qt being asynchronous, why do you need to handle the DBus messages in another thread ?

                  S Offline
                  S Offline
                  sootoo23
                  wrote on 16 Jul 2020, 02:44 last edited by
                  #8

                  @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.

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 16 Jul 2020, 14:47 last edited by
                    #9

                    Did you benchmark QtDBus with your GUI to see if you have that issue ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0

                    1/9

                    13 Jul 2020, 01:44

                    • Login

                    • Login or register to search.
                    1 out of 9
                    • First post
                      1/9
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved