Merge pull request #96 from gandrewstone/master

Avoid null pointer exception during compilation (race condition).

http://code.google.com/p/arduino/issues/detail?id=950
This commit is contained in:
David A. Mellis 2012-06-11 06:36:28 -07:00
commit 6d6f4424e4
3 changed files with 13 additions and 10 deletions

View File

@ -401,10 +401,8 @@ public class Compiler implements MessageConsumer {
boolean compiling = true;
while (compiling) {
try {
if (in.thread != null)
in.thread.join();
if (err.thread != null)
err.thread.join();
in.join();
err.join();
result = process.waitFor();
//System.out.println("result is " + result);
compiling = false;

View File

@ -85,8 +85,15 @@ public class MessageSiphon implements Runnable {
}
}
// Wait until the MessageSiphon thread is complete.
public void join() throws java.lang.InterruptedException {
// Grab a temp copy in case another thread nulls the "thread"
// member variable
Thread t = thread;
if (t != null) t.join();
}
public Thread getThread() {
return thread;
}
}
}

View File

@ -63,10 +63,8 @@ public class Sizer implements MessageConsumer {
while(running) {
try {
if (in.thread != null)
in.thread.join();
if (err.thread != null)
err.thread.join();
in.join();
err.join();
r = process.waitFor();
running = false;
} catch (InterruptedException intExc) { }