Fixed thread issue on windows
- Added a Platform.runLater on the Visualiser loops so that the notifying observers do not try to call it, where it is a non java-fx loop #story[881]
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
package seng302;
|
package seng302;
|
||||||
|
import javafx.application.Platform;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import seng302.Mock.*;
|
import seng302.Mock.*;
|
||||||
import seng302.Networking.BinaryMessageDecoder;
|
import seng302.Networking.BinaryMessageDecoder;
|
||||||
@@ -294,10 +295,12 @@ public class VisualiserInput implements Runnable {
|
|||||||
|
|
||||||
//System.out.println("XML Message!");
|
//System.out.println("XML Message!");
|
||||||
|
|
||||||
if (xmlMessage.getXmlMsgSubType() == XMLMessage.XMLTypeRegatta){
|
Platform.runLater(()-> {
|
||||||
|
if (xmlMessage.getXmlMsgSubType() == XMLMessage.XMLTypeRegatta) {
|
||||||
//System.out.println("Setting Regatta");
|
//System.out.println("Setting Regatta");
|
||||||
try {
|
try {
|
||||||
course.setRegattaXMLReader(new RegattaXMLReader(xmlMessage.getXmlMessage()));
|
course.setRegattaXMLReader(new RegattaXMLReader(xmlMessage.getXmlMessage()));
|
||||||
|
|
||||||
}
|
}
|
||||||
//TODO REFACTOR should put all of these exceptions behind a RegattaXMLReaderException.
|
//TODO REFACTOR should put all of these exceptions behind a RegattaXMLReaderException.
|
||||||
catch (IOException | SAXException | ParserConfigurationException e) {
|
catch (IOException | SAXException | ParserConfigurationException e) {
|
||||||
@@ -305,7 +308,7 @@ public class VisualiserInput implements Runnable {
|
|||||||
//Continue to the next loop iteration/message.
|
//Continue to the next loop iteration/message.
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (xmlMessage.getXmlMsgSubType() == XMLMessage.XMLTypeRace){
|
} else if (xmlMessage.getXmlMsgSubType() == XMLMessage.XMLTypeRace) {
|
||||||
//System.out.println("Setting Course");
|
//System.out.println("Setting Course");
|
||||||
try {
|
try {
|
||||||
course.setStreamedCourseXMLReader(new StreamedCourseXMLReader(xmlMessage.getXmlMessage()));
|
course.setStreamedCourseXMLReader(new StreamedCourseXMLReader(xmlMessage.getXmlMessage()));
|
||||||
@@ -316,10 +319,9 @@ public class VisualiserInput implements Runnable {
|
|||||||
//Continue to the next loop iteration/message.
|
//Continue to the next loop iteration/message.
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (xmlMessage.getXmlMsgSubType() == XMLMessage.XMLTypeBoat){
|
} else if (xmlMessage.getXmlMsgSubType() == XMLMessage.XMLTypeBoat) {
|
||||||
//System.out.println("Setting Boats");
|
//System.out.println("Setting Boats");
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
course.setBoatXMLReader(new BoatXMLReader(xmlMessage.getXmlMessage()));
|
course.setBoatXMLReader(new BoatXMLReader(xmlMessage.getXmlMessage()));
|
||||||
}
|
}
|
||||||
//TODO REFACTOR should put all of these exceptions behind a BoatXMLReaderException.
|
//TODO REFACTOR should put all of these exceptions behind a BoatXMLReaderException.
|
||||||
@@ -329,7 +331,7 @@ public class VisualiserInput implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
//RaceStartStatus.
|
//RaceStartStatus.
|
||||||
else if (message instanceof RaceStartStatus) {
|
else if (message instanceof RaceStartStatus) {
|
||||||
|
|||||||
Reference in New Issue
Block a user