Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Why does my single-threaded flow appear as 2 different threads in the debugger?

    General and Desktop
    2
    4
    638
    Loading More Posts
    • 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.
    • Q
      qttester5 last edited by

      I can see main.cpp running on thread 0 in the debugger, but also there are my function calls appearing on thread #7 in the debugger, but these are not calls I am sending to other threads.

      Why would they appear there?

      1 Reply Last reply Reply Quote 0
      • sierdzio
        sierdzio Moderators last edited by

        Qt will run some threads behind the scenes. It is likely that your function calls are triggered in the GUI, while main.cpp is in the "non-GUI" thread.

        (Z(:^

        1 Reply Last reply Reply Quote 0
        • Q
          qttester5 last edited by

          Looks like some of the functions are the result of callbacks from a socket connection, so perhaps that is why. This implies to me that I cannot assume there is a synchronous run loop in my program even if I am not manipulating threads directly. For example, I found one bug where apparently a function I directly call was running while a callback was only halfway through a callback function. I didn't even think that was possible. I'd expect one function to complete before another starts, but apparently not so.

          1 Reply Last reply Reply Quote 0
          • sierdzio
            sierdzio Moderators last edited by

            Qt is an event-based framework. This means that tasks are performed when the even loop invokes a handler for a given event. Some parts run separately from the event loop to speed things up. So yes, you should not assume your functions run sequentially, especially when using signal and slot connections.

            (Z(:^

            1 Reply Last reply Reply Quote 0
            • First post
              Last post