What is the difference between QThread::terminated() and QThread::finished()?
-
I am writing an application that gets frames from a camera. I need to release the camera resources. Should I do this in QThread::terminated() or QThread::finished()?
I would like to do it when the thread has completely finished executing all the code it had to execute.
-
Check the documentation: "QThread::terminate()":http://qt-project.org/doc/qt-5.0/qtcore/qthread.html#terminate is a slot that terminates the execution of the thread and "QThread::finished()":http://qt-project.org/doc/qt-5.0/qtcore/qthread.html#finished is a signal that is emitted by the thread before it finishes executing.
-
I am NOT referring to the slot QThread::terminate(). I am referring to the signal QThread::terminated().
-
terminated is emitted when the thread has been, well, terminated (forcibly stopped) which also means that it's state is not guaranteed to be clean.
-
[quote author="prerna" date="1370365766"]I am NOT referring to the slot QThread::terminate(). I am referring to the signal QThread::terminated().[/quote]
Please note that since Qt 5 the signal QThread::terminated() has been removed, because its emission cannot be guaranteed.