Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, February 2007
Inter-thread signalling YES or NO ?


Message 1 in thread

Hi all,

this will be probably a "clueless beginner" type of question. I've got
several years of MFC and Java experience and that's probably why i
have problems using correctly Qt's signal/slot architecture. Too much
initial self-confidence i suspect :)

The question is straight: what means a Qt runtime error "Cannot send
events to objects owned by a different thread" ? In my understanding,
it goes against the documentation of Qt::ConnectionType, where it says
"If the signal is emitted from the thread in which the receiving
object lives, the slot is invoked directly, as with
Qt::DirectConnection; otherwise the signal is queued, as with
Qt::QueuedConnection." I have understood the "otherwise" word as
"signal is emitted from other thread than the receivers affinity". I
have tested it with very simple two-thread app, that i definitely CAN
signal from object inside one thread to slot in object inside other
thread. Or is the error referring only to connection of type
Qt::DirectConnection() ? That i understand to be compiled as simple
function call and should work anyhow, shouldn't it?

I am not saying that everything is ok in my beginner
not-really-trivial multithreaded app (see the self-confidence rant
above). The assert message  blows on app shutdown and is originated in
QTcpSocket::close() living in a thread separate from the main. I am
not asking anyone to fix bugs in my app ( that's nonsense ) but to
explain me what the error message is saying.

Thanks,

Pavel Z.

--
 [ signature omitted ] 

Message 2 in thread

Hi,

> The question is straight: what means a Qt runtime error "Cannot send
> events to objects owned by a different thread" ? In my understanding,
> it goes against the documentation of Qt::ConnectionType, where it says
> "If the signal is emitted from the thread in which the receiving
> object lives, the slot is invoked directly, as with [...]

The above paragraph form the documentation refers to signals/slots.

The error message refers to events.

Signals/slots and events are different.

That said, I'm not certain why you're seeing this errror message. Could 
you post a compilable, minimal example that reproduces the problem?

--
 [ signature omitted ]