diff --git a/Htmldocs/release_notes.html b/Htmldocs/release_notes.html index cfb8a29c..8beabe59 100644 --- a/Htmldocs/release_notes.html +++ b/Htmldocs/release_notes.html @@ -49,6 +49,7 @@
  • [fix] Stop skipping the first 40 seconds of ResMed low-rate pressure data.
  • [fix] Correct Total Time and AHI in CSV Export when non-CPAP devices are used.
  • [fix] Fix value display and bookmark behavior with clock drift.
  • +
  • [fix] Ignore old sessions should not impact existing data.
  • Changes and fixes in OSCAR v1.2.0 diff --git a/oscar/SleepLib/machine.cpp b/oscar/SleepLib/machine.cpp index e8358382..afe58b1c 100644 --- a/oscar/SleepLib/machine.cpp +++ b/oscar/SleepLib/machine.cpp @@ -279,7 +279,11 @@ QDate Machine::pickDate(qint64 first) return date; } -bool Machine::AddSession(Session *s) +// allowOldSessions defaults to false and is only set to true when loading +// summary data on profile load. This true setting prevents old sessions from +// becoming lost if user preference indicates to not import sessions prior to a +// given date. +bool Machine::AddSession(Session *s, bool allowOldSessions) { if (s == nullptr) { qCritical() << "AddSession() called with a null object"; @@ -303,7 +307,10 @@ bool Machine::AddSession(Session *s) return false; } - if (profile->session->ignoreOlderSessions()) { + // allowOldSessions is true when loading summaries (already imported sessions) + // We don't want to throw away data already in the database in circumstances + // where user wants to ignore old sessions on import. + if (profile->session->ignoreOlderSessions() && !allowOldSessions) { qint64 ignorebefore = profile->session->ignoreOlderSessionsDate().toMSecsSinceEpoch(); if (s->last() < ignorebefore) { qDebug() << s->session() << "Ignoring old session"; @@ -783,7 +790,7 @@ bool Machine::Load(ProgressDialog *progress) // Forced to load it, because know nothing about this session.. if (sess->LoadSummary()) { - AddSession(sess); + AddSession(sess, true); } else { qWarning() << "Error loading summary file" << filename; delete sess; @@ -1019,7 +1026,7 @@ bool Machine::LoadSummary(ProgressDialog * progress) // } *****************************************************************/ Session * sess = it.value(); - if ( ! AddSession(sess)) { + if ( ! AddSession(sess, true)) { delete sess; } else { if (loadSummaries) { diff --git a/oscar/SleepLib/machine.h b/oscar/SleepLib/machine.h index 6de7a430..e9cd8f26 100644 --- a/oscar/SleepLib/machine.h +++ b/oscar/SleepLib/machine.h @@ -143,7 +143,7 @@ class Machine Session *SessionExists(SessionID session); //! \brief Adds the session to this machine object, and the Master Profile list. (used during load) - bool AddSession(Session *s); + bool AddSession(Session *s, bool allowOldSessions=false); //! \brief Find the date this session belongs in, according to profile settings QDate pickDate(qint64 start);