On 10/29/16 8:55 PM, rikki cattermole wrote:
On 30/10/2016 10:47 AM, Mergul wrote:
Application always crash when I'm using android_app.savedState.

if (state.savedState != null) {
    // We are starting with a previous saved state; restore from it.
    engine.state = *cast(saved_state*)state.savedState; //crash!

Don't compare against null using =, compare using is.

if (state.savedState !is null) {

android_app.savedState appears to be defined here:


It's a void *. So comparing against null with != is identical to !is.

There are actually cases where comparing against null with != is valid, and what you want exactly (e.g. comparing a string to null to check for empty string).

In this case, fixing the comparison is not the answer. What is happening is one of several things:

1. I don't know what type `engine` is, so if it's a pointer, then dereferencing the state member may be the culprit if engine is invalid. 2. If state is a pointer, then you could be crashing at the if statement (unlikely).
3. state or state.savedState isn't being properly initialized.
4. Something else (e.g. code generation error). Hope it's not this one.


Reply via email to