From 84a2b5cfd1bad61adfc76adb99569d7c8f845ddc Mon Sep 17 00:00:00 2001 From: sawinglogz <3787776-sawinglogz@users.noreply.gitlab.com> Date: Sat, 21 Mar 2020 17:41:35 -0400 Subject: [PATCH] Fix a crash when canceling a Zeo import. Also apply the same fix to Dreem import. Resolves #237. --- oscar/SleepLib/loader_plugins/dreem_loader.cpp | 11 +++++++++++ oscar/SleepLib/loader_plugins/dreem_loader.h | 4 ++-- oscar/SleepLib/loader_plugins/zeo_loader.cpp | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/oscar/SleepLib/loader_plugins/dreem_loader.cpp b/oscar/SleepLib/loader_plugins/dreem_loader.cpp index 6a08dd22..872dacca 100644 --- a/oscar/SleepLib/loader_plugins/dreem_loader.cpp +++ b/oscar/SleepLib/loader_plugins/dreem_loader.cpp @@ -23,6 +23,17 @@ static QSet s_unexpectedMessages; +DreemLoader::DreemLoader() +{ + m_type = MT_SLEEPSTAGE; + csv = nullptr; +} + +DreemLoader::~DreemLoader() +{ + closeCSV(); +} + bool DreemLoader::Detect(const QString & path) { diff --git a/oscar/SleepLib/loader_plugins/dreem_loader.h b/oscar/SleepLib/loader_plugins/dreem_loader.h index 7fd7ed52..d318d44e 100644 --- a/oscar/SleepLib/loader_plugins/dreem_loader.h +++ b/oscar/SleepLib/loader_plugins/dreem_loader.h @@ -20,8 +20,8 @@ const int dreem_data_version = 2; class DreemLoader : public MachineLoader { public: - DreemLoader() { m_type = MT_SLEEPSTAGE; } - virtual ~DreemLoader() { } + DreemLoader(); + virtual ~DreemLoader(); virtual bool Detect(const QString & path); diff --git a/oscar/SleepLib/loader_plugins/zeo_loader.cpp b/oscar/SleepLib/loader_plugins/zeo_loader.cpp index c9e0c467..e282d075 100644 --- a/oscar/SleepLib/loader_plugins/zeo_loader.cpp +++ b/oscar/SleepLib/loader_plugins/zeo_loader.cpp @@ -23,6 +23,7 @@ ZEOLoader::ZEOLoader() { m_type = MT_SLEEPSTAGE; + csv = nullptr; } ZEOLoader::~ZEOLoader() @@ -85,6 +86,7 @@ int ZEOLoader::Open(const QString & dirpath) int ZEOLoader::OpenFile(const QString & filename) { if (!openCSV(filename)) { + closeCSV(); return -1; } int count = 0;