unsigned long time)
{
bool pressed;
- safeLock(mouseMutex);
+ safeLock(inputMutex);
if (terminateThread) {
pressed = false;
} else {
- pressed = mouseCondition.wait(&mouseMutex, time) && !terminateThread;
+ pressed = inputCondition.wait(&inputMutex, time) && !terminateThread;
if (pressed) {
x = mousePos.x();
y = mousePos.y();
button = 0;
}
}
- safeUnlock(mouseMutex);
+ safeUnlock(inputMutex);
return pressed;
}
timer.stop();
thread->exit();
syncMutex.lock();
- mouseMutex.lock();
+ inputMutex.lock();
terminateThread = true; // this flag is needed for the case
// where the following wakeAll() call
// occurs between the
// mutex lock in safeLock() called
// from sync()
syncCondition.wakeAll();
- mouseCondition.wakeAll();
- mouseMutex.unlock();
+ inputCondition.wakeAll();
+ inputMutex.unlock();
syncMutex.unlock();
QWidget::closeEvent(ev);
if (!thread->wait(250)) {
*/
void DrawingWindow::mousePressEvent(QMouseEvent *ev)
{
- mouseMutex.lock();
+ inputMutex.lock();
mousePos = ev->pos();
mouseButton = ev->button();
ev->accept();
- mouseCondition.wakeAll();
- mouseMutex.unlock();
+ inputCondition.wakeAll();
+ inputMutex.unlock();
}
/*!
QBasicTimer timer;
QMutex imageMutex;
- QMutex mouseMutex;
- QWaitCondition mouseCondition;
+ QMutex inputMutex;
+ QWaitCondition inputCondition;
QMutex syncMutex;
QWaitCondition syncCondition;
bool terminateThread;