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
QtWS25 Last Chance

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
  • 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 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();
    }
    
    jsulmJ 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on 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
      0
      • SGaistS SGaist

        Hi,

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

        S Offline
        S Offline
        sootoo23
        wrote on 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
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on 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
          0
          • SGaistS SGaist

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

            S Offline
            S Offline
            sootoo23
            wrote on 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

              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();
              }
              
              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on 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
                1
                • SGaistS SGaist

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

                  S Offline
                  S Offline
                  sootoo23
                  wrote on 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
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 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

                    • Login

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