PDA

View Full Version : running() - Thread



sabeesh
8th October 2007, 11:19
Hi,
I have a code, it is in qt-3.2 and in that code there has two function, startcapture() and stopcapture().

In the startcapture() function, it has a sommand
start(); // start our own thread

I think it is for start the thread. and it is working

but In stopcapture ther has a command

QWaitCondition m_CaptureFinished;

if (running()) {
m_StopCapture = true;
m_CaptureFinished.wait();
qDebug("Capture thread stopped.");
}

I need to run it in QT4.3. I try for this, but when i make the program, it display an error like this,
================================================== ==========
error: ‘running’ was not declared in this scope

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)

================================================== ==============

please help me

marcel
8th October 2007, 11:28
See QThread::isRunning().

sabeesh
8th October 2007, 11:46
hi
thankyou for it and how can I ssolve this?

QWaitCondition m_CaptureFinished;
m_CaptureFinished.wait();

wysota
9th October 2007, 14:55
Solve what?

marcel
9th October 2007, 14:58
In Qt 4 wait needs a mutex to wait after.
So figure it out, do you need that wait there or not?

EDIT: I don't think that there even was a QWaitCondition in 3

marcel
9th October 2007, 19:45
QWaitCondition m_CaptureFinished;

if (running()) {
m_StopCapture = true;
m_CaptureFinished.wait();
qDebug("Capture thread stopped.");
}

Ok, that really makes no sense. I'm sure that code isn't from Qt 3. That works in Qt 4 only (almost :)).

Where is the mutex and why is the wait condition local? Do you have multiple threads in your application? QWaitCondition is used for synchronizing threads.