HumbleUI/JWM

Overridden close closes before checking if already closed

dzaima opened this issue · 1 comments

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.

@Override
public void close() {
assert _onUIThread();
_nClose();
super.close();
}

(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();?

Yeah that makes sense. PR?