HumbleUI / JWM

Cross-platform window management and OS integration library for Java
Apache License 2.0
547 stars 44 forks source link

Overridden close closes before checking if already closed #229

Closed dzaima closed 2 years ago

dzaima commented 2 years ago

The close method in Managed has a check for whether _ptr is zero, and throws an error if so. But if the method is overridden, e.g. https://github.com/HumbleUI/JWM/blob/b3f2289ce4635ce53219cddd00809e7fdcc4008c/shared/java/LayerGL.java#L59-L64 (this kind of thing happens in most overridden close methods) then the native close method will be called before that, resulting in a segfault, which is a lot less clear on what has happened.

This is a pretty minor thing all things considered, as it only affects code that's already incorrect, but I think it's still worth fixing.

Maybe replace assert _onUIThread(); with assert _onUIThread() && !isClosed();?

tonsky commented 2 years ago

Yeah that makes sense. PR?