Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Try to terminate thread in a more graceful manner, and avoid deadlock (race?).
authorArnaud Giersch <arnaud.giersch@free.fr>
Mon, 2 Dec 2013 08:26:02 +0000 (09:26 +0100)
committerArnaud Giersch <arnaud.giersch@free.fr>
Mon, 2 Dec 2013 09:27:06 +0000 (10:27 +0100)
CHANGES
DrawingWindow.cpp

diff --git a/CHANGES b/CHANGES
index 7177072..34651a2 100644 (file)
--- 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,
 -- dim. 10 nov. 2013 18:26:00 +0100
 
         * Contournement d'un bug avec certaines versions de Qt,
index 7015d6a..d1ef81b 100644 (file)
@@ -751,7 +751,7 @@ void DrawingWindow::usleep(unsigned long usecs)
 void DrawingWindow::closeEvent(QCloseEvent *ev)
 {
     timer.stop();
 void DrawingWindow::closeEvent(QCloseEvent *ev)
 {
     timer.stop();
-    thread->terminate();
+    thread->exit();
     syncMutex.lock();
     mouseMutex.lock();
     terminateThread = true;     // this flag is needed for the case
     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);
     mouseMutex.unlock();
     syncMutex.unlock();
     QWidget::closeEvent(ev);
-    thread->wait();
+    if (!thread->wait(250)) {
+        thread->terminate();
+        thread->wait();
+    }
 }
 
 /*!
 }
 
 /*!