From: Arnaud Giersch Date: Mon, 2 Dec 2013 08:26:02 +0000 (+0100) Subject: Try to terminate thread in a more graceful manner, and avoid deadlock (race?). X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/graphlib.git/commitdiff_plain/220646505f3b9d7a22749f7491ecc6c15bfec4f3 Try to terminate thread in a more graceful manner, and avoid deadlock (race?). --- 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(); + } } /*!