I have a problem with a loop in my code.
Basically I do this in a thread:
@while( !stop )
textResult = someLongProcessing(); // this takes ~50ms
}@ The signal is connected to the setValue() slot of a QLabel, so nothing really time consuming.
The problem is that sometimes someLongProcessing() returns immediately, causing the loop to emit a lot of signals.
My ram usage then increases a lot and the software crashes.
I can't call processEvents() because I'm not in the main thread. Then what should I do?
I can not handle the issue slot-side, since it's a qt slot.
If I add a sleep(5) in the loop it's better, but how would I know that the computer it's running on will need 5 or 10ms or even more to handle the setValue()...?
Thanks a lot for the help.
- EDIT: I just found about Qt::BlockingQueuedConnection, could this be a good idea?