robovm/robovm — pull request #659 by badlogic (2014-12-22 09:32:24+00:00)
Title: Fixes finalization error when current thread isn't fully initialized

Closes #649, finalization now also checks if there is a current thread in addition to an Env. If neither a thread or Env are available, the object is re-registered for finalization. If a finalization is performed, `rvmHasCurrentThread()` is invoked to check if both an `Env` and a `Thread` are available. The `Env` and `Thread` are stored in TLS in `attachThread()`. The thread TLS is set after the thread has been fully initialized. The TLSs are cleared in `detachThread()`.

Tested with a plain libGDX 1.5 app which invokes CoreMotion. App used to crash after at most 2 minutes. Test run with the fix didn't crash for 15 minutes. Note that this may be an insufficient test.