Fix Viatom loader glitch that prevented saving older sessions in a folder.

This commit is contained in:
sawinglogz 2020-04-26 14:06:48 -04:00
parent f75d5fab9d
commit 75bfdf2142
3 changed files with 16 additions and 8 deletions

View File

@ -25,6 +25,7 @@
<li>[fix] Fix the pressure waveform scale for the BiPAP autoSV Advanced 30 (960T)</li>
<li>[fix] Add support for rise time mode on DreamStation BiPAP devices (600X-700X).</li>
<li>[fix] Remove the ramp time and pressure settings when the ramp is disabled on pre-DreamStation devices.</li>
<li>[fix] Fix occasional failure to save imported Viatom data.</li>
</ul>
<p>
<b>Changes and fixes in OSCAR v1.1.0</b>

View File

@ -35,7 +35,7 @@ int
ViatomLoader::Open(const QString & dirpath)
{
qDebug() << "ViatomLoader::Open(" << dirpath << ")";
Machine* mach = nullptr;
m_mach = nullptr;
int imported = 0;
int found = 0;
s_unexpectedMessages.clear();
@ -47,21 +47,26 @@ ViatomLoader::Open(const QString & dirpath)
dir.setSorting(QDir::Name);
for (auto & fi : dir.entryInfoList()) {
mach = OpenFile(fi.canonicalFilePath());
if (mach) imported++;
if (OpenFile(fi.canonicalFilePath())) {
imported++;
}
found++;
}
}
else {
// This filename has already been filtered by QFileDialog.
mach = OpenFile(dirpath);
if (mach) imported++;
if (OpenFile(dirpath)) {
imported++;
}
found++;
}
if (!found) {
return -1;
}
Machine* mach = m_mach;
if (imported && mach == nullptr) qWarning() << "No machine record created?";
if (mach) {
qDebug() << "Imported" << imported << "sessions";
mach->Save();
@ -87,7 +92,7 @@ ViatomLoader::Open(const QString & dirpath)
return imported;
}
Machine* ViatomLoader::OpenFile(const QString & filename)
bool ViatomLoader::OpenFile(const QString & filename)
{
Machine* mach = nullptr;
@ -95,9 +100,10 @@ Machine* ViatomLoader::OpenFile(const QString & filename)
if (sess) {
SaveSessionToDatabase(sess);
mach = sess->machine();
m_mach = mach;
}
return mach;
return mach != nullptr;
}
Session* ViatomLoader::ParseFile(const QString & filename)

View File

@ -44,12 +44,13 @@ class ViatomLoader : public MachineLoader
//Machine *CreateMachine();
protected:
Machine* OpenFile(const QString & filename);
bool OpenFile(const QString & filename);
void SaveSessionToDatabase(Session* session);
void AddEvent(ChannelID channel, qint64 t, EventDataType value);
void EndEventList(ChannelID channel, qint64 t);
Machine* m_mach;
Session* m_session;
qint64 m_step;
QHash<ChannelID, EventList*> m_importChannels;