OpenCubicChunks / CubicChunksConverter

MIT License
8 stars 7 forks source link

make the GuiMain thread not block forever #8

Closed DaMatrix closed 3 years ago

Barteks2x commented 3 years ago

Why is that needed? I don't think you should need to run the GUI in any situation where blocking may matter

DaMatrix commented 3 years ago

well, in my case i'm launching the converter GUI from inside minecraft... i guess that's not really an expected use case though, so feel free to not merge if this is out-of-scope.

Barteks2x commented 3 years ago

Running the GUI in MC... that seems very wrong. But also, wrapping it in EventQueue.invokeLater should already be enough to make it not block

DaMatrix commented 3 years ago

i considered that, but figured there was some reason why you added the Thread.sleep() to keep the main thread alive. would doing that actually be safe?

Barteks2x commented 3 years ago

The reason I added the Thread.sleep() is that when I was initially writing the code, the JVM I ran it on probably had a bug where it would shut down the event loop thread and quit even after calling EventQueue.invokeLater if the main thread quit.

Barteks2x commented 3 years ago

Or you could just call EventQueue.invokeLater(() -> new GuiFrame().init()); yourself and make the change unnecessary. If you are shading the dependency into your jar, you probably won't care about forward version compatibility.

And that way you also avoid running the risk of silently triggering headless mode on weird JVMs

DaMatrix commented 3 years ago

true, alright then. closing.