Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Why does my single-threaded flow appear as 2 different threads in the debugger?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 759 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.
  • Q Offline
    Q Offline
    qttester5
    wrote on last edited by
    #1

    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
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      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
      0
      • Q Offline
        Q Offline
        qttester5
        wrote on last edited by
        #3

        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
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          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
          0

          • Login

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