infinitered / bluepotion

Like RedPotion, but for Android
MIT License
74 stars 18 forks source link

Crash if rotating device while an alert dialog is open #100

Open KCErb opened 9 years ago

KCErb commented 9 years ago

If you fire up an alert dialog and rotate the phone you'll get this:

Exception raised: NoMethodError: undefined method `[]' for nil:NilClass
  from alert_dialog.rb:47 in `onCreateDialog'

so it looks like onCreateDialog is getting called again after the rotation, but @options is gone? Not sure how that's possible. If it's calling the method on the instance shouldn't the instance variable still be around?

Ah but it's a new instance . . . interesting. When I put a mp self.inspect in the onCreateDialog method then I find that before rotation I get this:

#<AlertDialog:0x72e00019>

and after I rotate, just before the crash, I get this

#<AlertDialog:0x30000019>

I'll be looking around and seeing if this is something I can fix. In the meantime, if someone else has seen this kind of thing before (new class instances on rotation) and knows the right path forward, please let me know! :)

KCErb commented 9 years ago

Oh, I see now that this is a know TODO:

https://github.com/infinitered/bluepotion/blob/master/Rakefile#L46-L54

So now I guess the TODO has an issue along with it.

Also I think those lines from the Rakefile are meant to lock the app's orientation but my app's orientation isn't locked . . .