mirror of
https://github.com/ACINQ/eclair.git
synced 2025-02-23 06:35:11 +01:00
Moved eclair setup out of fx thread
This commit is contained in:
parent
2dd76c3b7b
commit
cff5ed2d3f
1 changed files with 9 additions and 17 deletions
|
@ -26,30 +26,23 @@ class FxApp extends Application with Logging {
|
||||||
|
|
||||||
val icon = new Image("/gui/commons/images/eclair02.png", true)
|
val icon = new Image("/gui/commons/images/eclair02.png", true)
|
||||||
primaryStage.getIcons().add(icon)
|
primaryStage.getIcons().add(icon)
|
||||||
|
|
||||||
val splashStage = new SplashStage()
|
val splashStage = new SplashStage()
|
||||||
splashStage.initOwner(primaryStage)
|
splashStage.initOwner(primaryStage)
|
||||||
splashStage.show
|
splashStage.show
|
||||||
|
|
||||||
val _this = this
|
|
||||||
|
|
||||||
new Thread(new Runnable {
|
new Thread(new Runnable {
|
||||||
override def run(): Unit = {
|
override def run(): Unit = {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
val setup = new Setup
|
||||||
|
val handlers = new Handlers(setup)
|
||||||
|
val controller = new MainController(handlers, primaryStage, setup)
|
||||||
|
val guiUpdater = setup.system.actorOf(Props(classOf[GUIUpdater], primaryStage, controller, setup), "gui-updater")
|
||||||
|
setup.system.eventStream.subscribe(guiUpdater, classOf[ChannelEvent])
|
||||||
|
setup.system.eventStream.subscribe(guiUpdater, classOf[NetworkEvent])
|
||||||
|
|
||||||
Platform.runLater(new Runnable {
|
Platform.runLater(new Runnable {
|
||||||
override def run(): Unit = {
|
override def run(): Unit = {
|
||||||
|
|
||||||
val setup = new Setup
|
|
||||||
val handlers = new Handlers(setup)
|
|
||||||
val controller = new MainController(handlers, primaryStage, setup)
|
|
||||||
val guiUpdater = setup.system.actorOf(Props(classOf[GUIUpdater], primaryStage, controller, setup), "gui-updater")
|
|
||||||
setup.system.eventStream.subscribe(guiUpdater, classOf[ChannelEvent])
|
|
||||||
setup.system.eventStream.subscribe(guiUpdater, classOf[NetworkEvent])
|
|
||||||
|
|
||||||
// get fxml/controller
|
// get fxml/controller
|
||||||
val mainFXML = new FXMLLoader(getClass.getResource("/gui/main/main.fxml"))
|
val mainFXML = new FXMLLoader(getClass.getResource("/gui/main/main.fxml"))
|
||||||
mainFXML.setController(controller)
|
mainFXML.setController(controller)
|
||||||
|
@ -68,7 +61,6 @@ class FxApp extends Application with Logging {
|
||||||
System.exit(0)
|
System.exit(0)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
splashStage.close()
|
splashStage.close()
|
||||||
primaryStage.setScene(scene)
|
primaryStage.setScene(scene)
|
||||||
primaryStage.show()
|
primaryStage.show()
|
||||||
|
@ -77,7 +69,7 @@ class FxApp extends Application with Logging {
|
||||||
|
|
||||||
} catch {
|
} catch {
|
||||||
case con: ConnectException => {
|
case con: ConnectException => {
|
||||||
logger.error(s"Error when connecting to bitcoin-core ${con}")
|
logger.error(s"Error when connecting to bitcoin-core", con)
|
||||||
Platform.runLater(new Runnable {
|
Platform.runLater(new Runnable {
|
||||||
override def run(): Unit = {
|
override def run(): Unit = {
|
||||||
splashStage.controller.showError("Could not connect to Bitcoin-core.")
|
splashStage.controller.showError("Could not connect to Bitcoin-core.")
|
||||||
|
@ -85,7 +77,7 @@ class FxApp extends Application with Logging {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
case e: Exception => {
|
case e: Exception => {
|
||||||
logger.error(s"Something wrong happened ${e}")
|
logger.error(s"Something wrong happened", e)
|
||||||
Platform.runLater(new Runnable {
|
Platform.runLater(new Runnable {
|
||||||
override def run(): Unit = {
|
override def run(): Unit = {
|
||||||
splashStage.controller.showError("An error has occured.")
|
splashStage.controller.showError("An error has occured.")
|
||||||
|
|
Loading…
Add table
Reference in a new issue