if (terminateThread) {
pressed = false;
} else {
- pressed = mouseCondition.wait(&mouseMutex, time);
+ pressed = mouseCondition.wait(&mouseMutex, time) && !terminateThread;
if (pressed) {
x = mousePos.x();
y = mousePos.y();
void DrawingWindow::closeEvent(QCloseEvent *ev)
{
timer.stop();
- thread->terminate();
+ thread->exit();
syncMutex.lock();
mouseMutex.lock();
terminateThread = true; // this flag is needed for the case
mouseMutex.unlock();
syncMutex.unlock();
QWidget::closeEvent(ev);
- thread->wait();
+ if (!thread->wait(250)) {
+ thread->terminate();
+ thread->wait();
+ }
}
/*!