From 83d0914145e12d532f2790b6a887723fb37fd112 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 4 Dec 2018 19:59:42 -0800 Subject: [PATCH] fix NPE It happened when too many timers were firing, but I think this code's better anyway. --- .../java/org/eehouse/android/xw4/BTService.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTService.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTService.java index 530e658fe..ec463e3a1 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTService.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTService.java @@ -1131,13 +1131,16 @@ public class BTService extends XWService { private void stopListener() { - m_listener.stopListening(); - try { - m_listener.join( 100 ); - } catch ( InterruptedException ie ) { - Log.ex( TAG, ie ); + BTListenerThread listener = m_listener; + if ( listener != null ) { + m_listener = null; + listener.stopListening(); + try { + listener.join( 100 ); + } catch ( InterruptedException ie ) { + Log.ex( TAG, ie ); + } } - m_listener = null; } private void stopSender()