Wireshark mailing list archives

Re: Slot on main thread not called when signal is emitted from another thread


From: Gerald Combs <gerald () wireshark org>
Date: Tue, 15 Dec 2015 13:19:15 -0800

On 12/15/15 8:15 AM, Paul Offord wrote:

When I run the code the extra thread starts OK and it starts to cycle
around the loop with the 3 second sleep. However, the connected slot
function Syncro::jumpToFrame(int new_frame) does not get called. If I
change the connect from QueuedConnection to DirectConnection the slot
function gets called but, as expected, in the context of my serviceThread.
I need the slot function to run on the main thread.

I guess it is because my jumpToFrame slot function is not on the main
thread event loop, but I don’t understand how to get it on the loop.

Can you try adding a constructor to Syncro, and add either

  moveToThread(QApplication::instance()->thread());

or

  setParent(QApplication::instance());

to it? I'm not sure if QObjects have a valid thread affinity by default.
___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscribe

Current thread: