PDA

View Full Version : Signal emits, but Slot seems to ignore it...



fluetke
22nd January 2011, 21:16
Hello everybody,

i've just recently stumbled into a problem, neither me nor my colleagues could solve.

For a mobile application, I created a Downloader class that emits a signal when a file has been saved.
This signal is connected to a slot in another class which updates some info about the downloaded file.
The call to connect() returned true, and the signal gets emitted, but the slot seems to completely ignore the signal.
I tested the signal by connecting it to a slot in the same class, and that slot is called.

Iam seriously stuck right now.
Maybe one of you can spot my error.

a minimal compilable example is included

tbscope
22nd January 2011, 21:49
How long does tmptrk live?
Answer that question and you have solved your problem :-)

fluetke
23rd January 2011, 00:31
oh my, thanks a lot.
I feel like a total idiot right now, how could I possibly not see that?
again thx a lot

aamer4yu
23rd January 2011, 08:32
How long does tmptrk live?
Can you throw more light on that ? I am not aware of tmptrk...

tbscope
23rd January 2011, 10:08
The poster created an object (tmptrack) on the stack within the scope of a function. The object got deleted before a signal could be sent.
Solutions are to use the stack but in such a way that the object has a long enough lifetime or to use the heap.


QList<Track*> AmzHandler::getTracklist()
{
// ...

Track tmptrk(QObject::tr("123456"));

// ...
}