mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
fix: add synchronized() to avoid concurrent modifications
between saveSettings() and discardNodeDB()
This commit is contained in:
parent
b3d581486a
commit
5d90584734
1 changed files with 2 additions and 3 deletions
|
|
@ -307,9 +307,8 @@ class MeshService : Service(), Logging {
|
|||
private fun getPrefs() = getSharedPreferences("service-prefs", Context.MODE_PRIVATE)
|
||||
|
||||
/// Save information about our mesh to disk, so we will have it when we next start the service (even before we hear from our device)
|
||||
private fun saveSettings() {
|
||||
private fun saveSettings() = synchronized(nodeDBbyNodeNum) {
|
||||
myNodeInfo?.let { myInfo ->
|
||||
val nodeDBbyNodeNum = nodeDBbyNodeNum.toMap()
|
||||
val settings = MeshServiceSettingsData(
|
||||
myInfo = myInfo,
|
||||
nodeDB = nodeDBbyNodeNum.values.toTypedArray(),
|
||||
|
|
@ -356,7 +355,7 @@ class MeshService : Service(), Logging {
|
|||
/**
|
||||
* discard entire node db & message state - used when downloading a new db from the device
|
||||
*/
|
||||
private fun discardNodeDB() {
|
||||
private fun discardNodeDB() = synchronized(nodeDBbyNodeNum) {
|
||||
debug("Discarding NodeDB")
|
||||
myNodeInfo = null
|
||||
nodeDBbyNodeNum.clear()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue