From 220646505f3b9d7a22749f7491ecc6c15bfec4f3 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Mon, 2 Dec 2013 09:26:02 +0100 Subject: [PATCH] Try to terminate thread in a more graceful manner, and avoid deadlock (race?). --- CHANGES | 4 ++++ DrawingWindow.cpp | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 7177072..34651a2 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +-- lun. 02 déc. 2013 09:26:02 +0100 + + * Correction d'un problème de blocage à la fin de l'exécution. + -- dim. 10 nov. 2013 18:26:00 +0100 * Contournement d'un bug avec certaines versions de Qt, diff --git a/DrawingWindow.cpp b/DrawingWindow.cpp index 7015d6a..d1ef81b 100644 --- a/DrawingWindow.cpp +++ b/DrawingWindow.cpp @@ -751,7 +751,7 @@ void DrawingWindow::usleep(unsigned long usecs) void DrawingWindow::closeEvent(QCloseEvent *ev) { timer.stop(); - thread->terminate(); + thread->exit(); syncMutex.lock(); mouseMutex.lock(); terminateThread = true; // this flag is needed for the case @@ -765,7 +765,10 @@ void DrawingWindow::closeEvent(QCloseEvent *ev) mouseMutex.unlock(); syncMutex.unlock(); QWidget::closeEvent(ev); - thread->wait(); + if (!thread->wait(250)) { + thread->terminate(); + thread->wait(); + } } /*! -- 2.20.1