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();
+ }
}
/*!
*/
void DrawingWindow::keyPressEvent(QKeyEvent *ev)
{
- bool accept = true;
- switch (ev->key()) {
- case Qt::Key_Escape:
+ if (ev->key() == Qt::Key_Escape) {
+ ev->accept();
close();
- break;
- default:
- accept = false;
- break;
}
- if (accept)
- ev->accept();
}
/*!