bladecoder / bladecoder-adventure-engine

Classic point and click adventure game engine and editor
Apache License 2.0
602 stars 65 forks source link

Invoking JavaFX from within the ui thread #24

Closed johanneslerch closed 8 years ago

johanneslerch commented 8 years ago

If i try to run the editor via gradlew run or via launching Main.main from within Eclipse i get the following exception:

Exception in thread "main" java.lang.ExceptionInInitializerError at com.bladecoder.engineeditor.Main.main(Main.java:42) Caused by: java.lang.IllegalStateException: This operation is permitted on the event thread only; currentThread = main at com.sun.glass.ui.Application.checkEventThread(Unknown Source) at com.sun.glass.ui.Screen.setEventHandler(Unknown Source) at com.sun.javafx.tk.quantum.QuantumToolkit.setScreenConfigurationListener(Unknown Source) at javafx.stage.Screen.(Unknown Source) ... 1 more

Not sure why you did not encounter similar issues, yet. But, by simply wrapping the code in the main method by a call to Platform.runLater the issue is fixed.

bladecoder commented 8 years ago

Hi Johannes,

Thank you for your PR. I wasn't able to reproduce the issue, the editor runs ok for me but I think that using JavaFx to get the screen resolution is not necessary, I can use Libgdx so I reduce the dependency from JavaFx.

I commit the fix in master, can you check if it works for you?

Thank you.

johanneslerch commented 8 years ago

Hi, that solved the issue as well, thank you!