A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
graphlib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Try to terminate thread in a more graceful manner, and avoid deadlock (race?).
[graphlib.git]
/
DrawingWindow.cpp
diff --git
a/DrawingWindow.cpp
b/DrawingWindow.cpp
index
1ab14ee
..
d1ef81b
100644
(file)
--- a/
DrawingWindow.cpp
+++ b/
DrawingWindow.cpp
@@
-669,7
+669,7
@@
bool DrawingWindow::waitMousePress(int &x, int &y, int &button,
if (terminateThread) {
pressed = false;
} else {
if (terminateThread) {
pressed = false;
} else {
- pressed = mouseCondition.wait(&mouseMutex, time);
+ pressed = mouseCondition.wait(&mouseMutex, time)
&& !terminateThread
;
if (pressed) {
x = mousePos.x();
y = mousePos.y();
if (pressed) {
x = mousePos.x();
y = mousePos.y();
@@
-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();
+ }
}
/*!
}
/*!