PDA

View Full Version : QWaitCondition



sabeesh
24th October 2007, 12:22
Hi,
I had a code in Qt-3.2. its like this,

QWaitCondition m_CaptureFinished;

if (running()) {
qDebug("Waiting for capture thread to stop...");
m_StopCapture = true;
m_CaptureFinished.wait();
qDebug("Capture thread stopped.");
}

and this section is working in Qt-3.2. But When I try this code then it display an error like this
error: no matching function for call to ‘QWaitCondition::wait()’
/usr/local/Trolltech/Qt-4.3.0/include/QtCore/qwaitcondition.h:44: note: candidates are: bool QWaitCondition::wait(QMutex*, long unsigned int)

Then I try like this

if (isRunning()) {
m_BufMutex.lock();
qDebug("Waiting for capture thread to stop...");
m_StopCapture = true;
m_CaptureFinished.wait(&m_BufMutex);
qDebug("Capture thread stopped.");
}

Then doesn't display any error when I make the program. But at run time the program is crashed due to the thread is not stoped. How can I solve this ploblem.
Please help me.....

DeepDiver
24th October 2007, 16:15
It's hard to tell, whats going on in your program.
We need to see the code piece calling wakeOne() or wakeAll().
Maybe you have some deadlock situation.

One thing making me wonder is:
In your example you never call m_BufMutex.unlock().

Good luck,

Tom