Skip to content

Commit

Permalink
Ensure that finish() means no more screenshots are taken
Browse files Browse the repository at this point in the history
This fixes broken animated gifs I've seen where an additional image was
written on after the gif was 'finished'.

This was basically a race condition between the log-listener thread and
the main thread - the main thread will now block while waiting for
the last screenshot to be taken if it's already in progress, which works
much better.
  • Loading branch information
rtyley committed Feb 28, 2012
1 parent 693138c commit 79669e4
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void start() {
*/
public void finish() {
if (logListenerCommandShell != null) {
logListenerCommandShell.cancelled = true;
logListenerCommandShell.cancel();
}
for (ScreenshotProcessor screenshotProcessor : processors) {
screenshotProcessor.finish();
Expand Down Expand Up @@ -86,13 +86,17 @@ public void activate() {
activated = true;
}

public synchronized void cancel() {
cancelled = true;
}

@Override
public boolean isCancelled() {
return cancelled;
}

@Override
public void processNewLines(String[] lines) {
public synchronized void processNewLines(String[] lines) {
if (!activated || cancelled) {
// log.debug("Ignoring "+lines+" lines of log");
return;
Expand Down

0 comments on commit 79669e4

Please sign in to comment.