Commit 5052b748 authored by Max Lv's avatar Max Lv

fix a race condition

parent cefe9b17
...@@ -322,7 +322,7 @@ class Shadowsocks ...@@ -322,7 +322,7 @@ class Shadowsocks
case ignored: RemoteException => // Nothing case ignored: RemoteException => // Nothing
} }
// Update the UI // Update the UI
switchButton.setEnabled(true) if (switchButton != null) switchButton.setEnabled(true)
if (State.isAvailable(bgService.getState)) { if (State.isAvailable(bgService.getState)) {
Crouton.cancelAllCroutons() Crouton.cancelAllCroutons()
setPreferenceEnabled(enabled = true) setPreferenceEnabled(enabled = true)
...@@ -334,9 +334,9 @@ class Shadowsocks ...@@ -334,9 +334,9 @@ class Shadowsocks
} }
override def onServiceDisconnected(name: ComponentName) { override def onServiceDisconnected(name: ComponentName) {
switchButton.setEnabled(false) if (switchButton != null) switchButton.setEnabled(false)
try { try {
bgService.unregisterCallback(callback) if (bgService != null) bgService.unregisterCallback(callback)
} catch { } catch {
case ignored: RemoteException => // Nothing case ignored: RemoteException => // Nothing
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment