platypusllc / tablet

Source code for Platypus tablet android app
BSD 3-Clause "New" or "Revised" License
1 stars 5 forks source link

Null pointer exception if long press used without colored pencil #52

Open jjblum opened 7 years ago

jjblum commented 7 years ago

Does not occur if the pencil ever becomes colored. Once it is turned back to black the app will not crash on long press.

AndroidRuntime [E] FATAL EXCEPTION: main
AndroidRuntime [E] Process: com.platypus.android.tablet, PID: 4871
AndroidRuntime [E] java.lang.NullPointerException: Attempt to invoke virtual method 'void com.platypus.android.tablet.Path.Path.updateRegionPoints()' on a null o bject reference
AndroidRuntime [E] at com.platypus.android.tablet.TeleOpPanel.invalidate(TeleOpPanel.java: 2721)
AndroidRuntime [E] at com.platypus.android.tablet.TeleOpPanel$7$2.onMapLongClick(TeleOpPan el.java:689)
AndroidRuntime [E] at com.mapbox.mapboxsdk.maps.MapView$GestureListener.onLongPress(MapVie w.java:1976)
AndroidRuntime [E] at android.view.GestureDetector.dispatchLongPress(GestureDetector.java: 690)
AndroidRuntime [E] at android.view.GestureDetector.access$200(GestureDetector.java:37)
AndroidRuntime [E] at android.view.GestureDetector$GestureHandler.handleMessage(GestureDet ector.java:266)
AndroidRuntime [E] at android.os.Handler.dispatchMessage(Handler.java:102)
AndroidRuntime [E] at android.os.Looper.loop(Looper.java:135)
AndroidRuntime [E] at android.app.ActivityThread.main(ActivityThread.java:5484)
AndroidRuntime [E] at java.lang.reflect.Method.invoke(Native Method)
AndroidRuntime [E] at java.lang.reflect.Method.invoke(Method.java:372)
AndroidRuntime [E] at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteIni t.java:984)
AndroidRuntime [E] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)

jjblum commented 7 years ago

Suggested change:

In TeleOpPanel.invalidate(), make sure boatPath.updateRegionPoints() is inside a check for boatPath != null:

if (boatPath != null) { boatPath.updateRegionPoints(); } else { return; }