From 26155a28dc79df40af40a02dbd85bf9fc67b264d Mon Sep 17 00:00:00 2001 From: Luis Uguina Date: Mon, 11 May 2020 21:51:36 +1000 Subject: [PATCH] Fix: racing condition with messages when the queue is full (#223) There was a racing condition between the queue full message and *any* error message where the later are overwritten by the former. --- src/com/sheepit/client/Client.java | 15 +++++++++------ src/com/sheepit/client/standalone/GuiSwing.java | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/com/sheepit/client/Client.java b/src/com/sheepit/client/Client.java index b98f269..109f4b5 100644 --- a/src/com/sheepit/client/Client.java +++ b/src/com/sheepit/client/Client.java @@ -358,12 +358,15 @@ public class Client { this.renderingJob = null; } - while (this.shouldWaitBeforeRender() == true) { - try { - Thread.sleep(4000); // wait a little bit - this.gui.status("Sending frames. Please wait"); - } - catch (InterruptedException e3) { + if (this.shouldWaitBeforeRender() == true) { + this.gui.status("Sending frames. Please wait"); + + while (this.shouldWaitBeforeRender() == true) { + try { + Thread.sleep(4000); // wait a little bit + } + catch (InterruptedException e3) { + } } } this.log.removeCheckPoint(step); diff --git a/src/com/sheepit/client/standalone/GuiSwing.java b/src/com/sheepit/client/standalone/GuiSwing.java index ba4dc33..f48273e 100644 --- a/src/com/sheepit/client/standalone/GuiSwing.java +++ b/src/com/sheepit/client/standalone/GuiSwing.java @@ -206,7 +206,7 @@ public class GuiSwing extends JFrame implements Gui { @Override public void error(String msg_) { - status(msg_); + status(msg_, true); } @Override