PDA

View Full Version : SIGNAL/SLOT - Object scope?



StarShaper
19th February 2012, 11:37
I was curious what is the scope of an object, if I do that.


void myMethod() {
Object o;
emit MySignal(o);


If I transfer the object to another thread, what happens to the object scope? o is allocated on stack.

wysota
19th February 2012, 12:42
The object always goes out of scope when the function returns. The signal carries a copy of the object in case of a cross-thread emission and a copy or a cost or non-const reference in case of a direct call.

StarShaper
19th February 2012, 13:35
The object always goes out of scope when the function returns. The signal carries a copy of the object in case of a cross-thread emission and a copy or a cost or non-const reference in case of a direct call.

Thanks! :)