tsiemens / pathfinder-toolkit

A Pathfinder RPG Android app, for managing characters and parties
22 stars 6 forks source link

Crash after trying to display invalid skill #9

Closed tsiemens closed 10 years ago

tsiemens commented 10 years ago

Affects version: 2.0 Device: Optimus G Pro, XT910 Android Version: 4.1

User crash reports:

App closes when selecting "show trained only" in the skills tab.

I adjusted a skill on a character then it crashed. Now it crashes whenever I try to access the skills screen for that character only

java.lang.NullPointerException
at com.lateensoft.pathfinder.toolkit.model.character.stats.PTAbilitySet.getTotalAbilityMod(PTAbilitySet.java:115)
at com.lateensoft.pathfinder.toolkit.model.character.stats.PTSkill.getSkillMod(PTSkill.java:95)
at com.lateensoft.pathfinder.toolkit.adapters.character.PTSkillsAdapter.getView(PTSkillsAdapter.java:72)
at android.widget.AbsListView.obtainView(AbsListView.java:2306)
at android.widget.ListView.makeAndAddView(ListView.java:1771)
at android.widget.ListView.fillDown(ListView.java:673)
at android.widget.ListView.fillFromTop(ListView.java:735)
at android.widget.ListView.layoutChildren(ListView.java:1624)
at android.widget.AbsListView.onLayout(AbsListView.java:2141)
at android.view.View.layout(View.java:13878)
at android.view.ViewGroup.layout(ViewGroup.java:4367)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1672)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1530)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1443)
at android.view.View.layout(View.java:13878)
at android.view.ViewGroup.layout(ViewGroup.java:4367)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13878)
at android.view.ViewGroup.layout(ViewGroup.java:4367)
at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:653)
at android.view.View.layout(View.java:13878)
at android.view.ViewGroup.layout(ViewGroup.java:4367)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13878)
at android.view.ViewGroup.layout(ViewGroup.java:4367)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1672)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1530)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1443)
at android.view.View.layout(View.java:13878)
at android.view.ViewGroup.layout(ViewGroup.java:4367)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13878)
at android.view.ViewGroup.layout(ViewGroup.java:4367)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1900)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1716)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1019)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4276)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4886)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)
tsiemens commented 10 years ago

From what I can tell, somehow the skill had an invalid ability key. It may be prudent to add InvalidStateException or InvalidArgumentException to some methods to make errors more clear in the stackstrace.

tsiemens commented 10 years ago

Stack traces should indicate the issue more clearly now, if this is still occurring. To fix errors which are likely now stored in user's databases, added integrity checks. Also added a check on returning from the editor, in case this is the source of the error in the first place.