Why does my single-threaded flow appear as 2 different threads in the debugger?
-
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.
-
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.
-
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.