Fix for crashes that got introduced by moving statistics calculations to background thread

The crashes were due to the background thread that was using BgReading instances on a private managed object context, however those BgReadings were already deleted in the main managed object context, but without saving.
There's no a save to core data done immediately after deleting a BgReading, this seems to fix the crashes
This commit is contained in:
Johan Degraeve 2021-05-01 20:31:42 +02:00
parent f731f00e60
commit c440b351b5
2 changed files with 6 additions and 0 deletions

View File

@ -84,6 +84,8 @@ class HouseKeeper {
bgReadingsAccessor.delete(bgReading: oldReading, on: managedObjectContext)
coreDataManager.saveChanges()
}
}
@ -110,6 +112,8 @@ class HouseKeeper {
} else {
calibrationsAccessor.delete(calibration: oldCalibration, on: managedObjectContext)
coreDataManager.saveChanges()
}

View File

@ -733,6 +733,8 @@ final class RootViewController: UIViewController {
coreDataManager.mainManagedObjectContext.delete(reading)
coreDataManager.saveChanges()
}
// as we're deleting readings, glucoseChartPoints need to be updated, otherwise we keep seeing old values