From f463990029c97b231f167c05fa33368df37e38f6 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Sat, 20 Jul 2019 08:36:43 +0200 Subject: [PATCH] Fix potential NPE in startup guide DroidFish.reInitUI() could potentially set tourGuide to null while tap events are already queued but not yet processed. Avoid NPE in this situation. --- .../src/main/java/org/petero/droidfish/DroidFish.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/DroidFishApp/src/main/java/org/petero/droidfish/DroidFish.java b/DroidFishApp/src/main/java/org/petero/droidfish/DroidFish.java index 8b3ef3b..de3eed9 100644 --- a/DroidFishApp/src/main/java/org/petero/droidfish/DroidFish.java +++ b/DroidFishApp/src/main/java/org/petero/droidfish/DroidFish.java @@ -680,14 +680,19 @@ public class DroidFish extends Activity Editor editor = settings.edit(); editor.putBoolean("guideShowOnStart", false); editor.apply(); - tourGuide.next(); - tourGuide = null; + if (tourGuide != null) { + tourGuide.next(); + tourGuide = null; + } })); Sequence sequence = new Sequence.SequenceBuilder() .add(guides.toArray(new TourGuide[0])) .setDefaultOverlay(new Overlay() - .setOnClickListener(v -> tourGuide.next())) + .setOnClickListener(v -> { + if (tourGuide != null) + tourGuide.next(); + })) .setDefaultPointer(new Pointer()) .setContinueMethod(Sequence.ContinueMethod.OverlayListener) .build();