Merge pull request #596 from jotomo/tbr-active-check-race-condition

Avoid race condition checking for an active TBR.
This commit is contained in:
Milos Kozak 2018-01-13 22:43:41 +01:00 committed by GitHub
commit fdbd2a2cb1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 8 deletions

View file

@ -631,7 +631,7 @@ public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, Tr
@Override @Override
@Nullable @Nullable
public TemporaryBasal getTempBasalFromHistory(long time) { public TemporaryBasal getTempBasalFromHistory(long time) {
return activeTreatments.getTempBasalFromHistory(time); return activeTreatments != null ? activeTreatments.getTempBasalFromHistory(time) : null;
} }
@Override @Override

View file

@ -139,8 +139,8 @@ public class PersistentNotificationPlugin implements PluginBase {
} }
} }
if (MainApp.getConfigBuilder().isTempBasalInProgress()) { TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()); if (activeTemp != null) {
line1 += " " + activeTemp.toStringShort(); line1 += " " + activeTemp.toStringShort();
} }

View file

@ -403,8 +403,10 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
@Override @Override
public double getTempBasalRemainingMinutesFromHistory() { public double getTempBasalRemainingMinutesFromHistory() {
if (isTempBasalInProgress()) TemporaryBasal activeTemp = getTempBasalFromHistory(System.currentTimeMillis());
return getTempBasalFromHistory(System.currentTimeMillis()).getPlannedRemainingMinutes(); if (activeTemp != null) {
return activeTemp.getPlannedRemainingMinutes();
}
return 0; return 0;
} }

View file

@ -182,10 +182,9 @@ public class StatuslinePlugin implements PluginBase {
//Temp basal //Temp basal
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder(); TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
if (treatmentsInterface.isTempBasalInProgress()) { TemporaryBasal activeTemp = treatmentsInterface.getTempBasalFromHistory(System.currentTimeMillis());
TemporaryBasal activeTemp = treatmentsInterface.getTempBasalFromHistory(System.currentTimeMillis()); if (activeTemp != null) {
status += activeTemp.toStringShort(); status += activeTemp.toStringShort();
} }
//IOB //IOB