From 0dba31e58ba6ceb41d58edc9a9af0a9383129ae6 Mon Sep 17 00:00:00 2001 From: Phil Olynyk Date: Tue, 21 Jan 2020 13:49:02 -0500 Subject: [PATCH 1/3] Changes for old QT and compiler versions --- oscar/SleepLib/loader_plugins/prs1_loader.cpp | 20 +++++++++++++++++++ oscar/oscar.pro | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/oscar/SleepLib/loader_plugins/prs1_loader.cpp b/oscar/SleepLib/loader_plugins/prs1_loader.cpp index f0daf26e..de9ee806 100644 --- a/oscar/SleepLib/loader_plugins/prs1_loader.cpp +++ b/oscar/SleepLib/loader_plugins/prs1_loader.cpp @@ -891,7 +891,11 @@ void PRS1Loader::ScanFiles(const QStringList & paths, int sessionid_base, Machin QDateTime datetime; +#if QT_VERSION < QT_VERSION_CHECK(5,8,0) + qint64 ignoreBefore = p_profile->session->ignoreOlderSessionsDate().toMSecsSinceEpoch()/1000; +#else qint64 ignoreBefore = p_profile->session->ignoreOlderSessionsDate().toSecsSinceEpoch(); +#end bool ignoreOldSessions = p_profile->session->ignoreOlderSessions(); QSet skipped; @@ -1014,9 +1018,15 @@ void PRS1Loader::ScanFiles(const QStringList & paths, int sessionid_base, Machin continue; } if (ignoreOldSessions && chunk->timestamp < ignoreBefore) { +#if QT_VERSION < QT_VERSION_CHECK(5,8,0) + qDebug().noquote() << relativePath(path) << "skipping session" << chunk_sid << ":" + << QDateTime::fromMSecsSinceEpoch(chunk->timestamp*1000).toString() << "older than" + << QDateTime::fromMSecsSinceEpoch(ignoreBefore*1000).toString(); +#else qDebug().noquote() << relativePath(path) << "skipping session" << chunk_sid << ":" << QDateTime::fromSecsSinceEpoch(chunk->timestamp).toString() << "older than" << QDateTime::fromSecsSinceEpoch(ignoreBefore).toString(); +#end skipped += chunk_sid; delete chunk; continue; @@ -7683,14 +7693,24 @@ QList PRS1Import::CoalesceWaveformChunks(QList // This won't be perfect, since any coalesced chunks starting after midnight of the threshhold // date will also be imported, but those should be relatively few, and tolerable imprecision. QList coalescedAndFiltered; +#if QT_VERSION < QT_VERSION_CHECK(5,8,0) + qint64 ignoreBefore = p_profile->session->ignoreOlderSessionsDate().toMSecsSinceEpoch()/1000; +#else qint64 ignoreBefore = p_profile->session->ignoreOlderSessionsDate().toSecsSinceEpoch(); +#end bool ignoreOldSessions = p_profile->session->ignoreOlderSessions(); for (auto & chunk : coalesced) { if (ignoreOldSessions && chunk->timestamp < ignoreBefore) { +#if QT_VERSION < QT_VERSION_CHECK(5,8,0) + qWarning().noquote() << relativePath(chunk->m_path) << "skipping session" << chunk->sessionid << ":" + << QDateTime::fromMSecsSinceEpoch(chunk->timestamp*1000).toString() << "older than" + << QDateTime::fromMSecsSinceEpoch(ignoreBefore*1000).toString(); +#else qWarning().noquote() << relativePath(chunk->m_path) << "skipping session" << chunk->sessionid << ":" << QDateTime::fromSecsSinceEpoch(chunk->timestamp).toString() << "older than" << QDateTime::fromSecsSinceEpoch(ignoreBefore).toString(); +#end continue; } coalescedAndFiltered.append(chunk); diff --git a/oscar/oscar.pro b/oscar/oscar.pro index 5bcada12..6c9f67bb 100644 --- a/oscar/oscar.pro +++ b/oscar/oscar.pro @@ -483,6 +483,10 @@ memdebug { !win32 { # add memory checking on Linux and macOS debug builds QMAKE_CFLAGS += -g -Werror -fsanitize=address -fno-omit-frame-pointer -fno-common -fsanitize-address-use-after-scope QMAKE_CXXFLAGS += -g -Werror -fsanitize=address -fno-omit-frame-pointer -fno-common -fsanitize-address-use-after-scope + lessThan(QT_MAJOR_VERSION,5)|lessThan(QT_MINOR_VERSION,9) { + QMAKE_CFLAGS -= -fsanitize-address-use-after-scope + QMAKE_CXX_FLAGS -= -fsanitize-address-use-after-scope + } QMAKE_LFLAGS += -fsanitize=address } } From 04c085f924118eeeb6fdf681c34c9cb52b2ac67e Mon Sep 17 00:00:00 2001 From: Phil Olynyk Date: Tue, 21 Jan 2020 15:53:08 -0500 Subject: [PATCH 2/3] Add code to use old calls with old Qt versions --- oscar/SleepLib/loader_plugins/prs1_loader.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/oscar/SleepLib/loader_plugins/prs1_loader.cpp b/oscar/SleepLib/loader_plugins/prs1_loader.cpp index de9ee806..58d09b87 100644 --- a/oscar/SleepLib/loader_plugins/prs1_loader.cpp +++ b/oscar/SleepLib/loader_plugins/prs1_loader.cpp @@ -895,7 +895,7 @@ void PRS1Loader::ScanFiles(const QStringList & paths, int sessionid_base, Machin qint64 ignoreBefore = p_profile->session->ignoreOlderSessionsDate().toMSecsSinceEpoch()/1000; #else qint64 ignoreBefore = p_profile->session->ignoreOlderSessionsDate().toSecsSinceEpoch(); -#end +#endif bool ignoreOldSessions = p_profile->session->ignoreOlderSessions(); QSet skipped; @@ -1026,7 +1026,7 @@ void PRS1Loader::ScanFiles(const QStringList & paths, int sessionid_base, Machin qDebug().noquote() << relativePath(path) << "skipping session" << chunk_sid << ":" << QDateTime::fromSecsSinceEpoch(chunk->timestamp).toString() << "older than" << QDateTime::fromSecsSinceEpoch(ignoreBefore).toString(); -#end +#endif skipped += chunk_sid; delete chunk; continue; @@ -7697,7 +7697,7 @@ QList PRS1Import::CoalesceWaveformChunks(QList qint64 ignoreBefore = p_profile->session->ignoreOlderSessionsDate().toMSecsSinceEpoch()/1000; #else qint64 ignoreBefore = p_profile->session->ignoreOlderSessionsDate().toSecsSinceEpoch(); -#end +#endif bool ignoreOldSessions = p_profile->session->ignoreOlderSessions(); for (auto & chunk : coalesced) { @@ -7710,7 +7710,7 @@ QList PRS1Import::CoalesceWaveformChunks(QList qWarning().noquote() << relativePath(chunk->m_path) << "skipping session" << chunk->sessionid << ":" << QDateTime::fromSecsSinceEpoch(chunk->timestamp).toString() << "older than" << QDateTime::fromSecsSinceEpoch(ignoreBefore).toString(); -#end +#endif continue; } coalescedAndFiltered.append(chunk); From 80edf9d4f97fe39ca1cb98ba1017b5cd1476ccfb Mon Sep 17 00:00:00 2001 From: Phil Olynyk Date: Wed, 22 Jan 2020 14:23:37 -0500 Subject: [PATCH 3/3] Always use pre5.8 mSec to/from epoch calls --- oscar/SleepLib/loader_plugins/prs1_loader.cpp | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/oscar/SleepLib/loader_plugins/prs1_loader.cpp b/oscar/SleepLib/loader_plugins/prs1_loader.cpp index 58d09b87..d1ebb968 100644 --- a/oscar/SleepLib/loader_plugins/prs1_loader.cpp +++ b/oscar/SleepLib/loader_plugins/prs1_loader.cpp @@ -891,11 +891,7 @@ void PRS1Loader::ScanFiles(const QStringList & paths, int sessionid_base, Machin QDateTime datetime; -#if QT_VERSION < QT_VERSION_CHECK(5,8,0) qint64 ignoreBefore = p_profile->session->ignoreOlderSessionsDate().toMSecsSinceEpoch()/1000; -#else - qint64 ignoreBefore = p_profile->session->ignoreOlderSessionsDate().toSecsSinceEpoch(); -#endif bool ignoreOldSessions = p_profile->session->ignoreOlderSessions(); QSet skipped; @@ -1018,15 +1014,9 @@ void PRS1Loader::ScanFiles(const QStringList & paths, int sessionid_base, Machin continue; } if (ignoreOldSessions && chunk->timestamp < ignoreBefore) { -#if QT_VERSION < QT_VERSION_CHECK(5,8,0) qDebug().noquote() << relativePath(path) << "skipping session" << chunk_sid << ":" << QDateTime::fromMSecsSinceEpoch(chunk->timestamp*1000).toString() << "older than" << QDateTime::fromMSecsSinceEpoch(ignoreBefore*1000).toString(); -#else - qDebug().noquote() << relativePath(path) << "skipping session" << chunk_sid << ":" - << QDateTime::fromSecsSinceEpoch(chunk->timestamp).toString() << "older than" - << QDateTime::fromSecsSinceEpoch(ignoreBefore).toString(); -#endif skipped += chunk_sid; delete chunk; continue; @@ -7693,24 +7683,14 @@ QList PRS1Import::CoalesceWaveformChunks(QList // This won't be perfect, since any coalesced chunks starting after midnight of the threshhold // date will also be imported, but those should be relatively few, and tolerable imprecision. QList coalescedAndFiltered; -#if QT_VERSION < QT_VERSION_CHECK(5,8,0) qint64 ignoreBefore = p_profile->session->ignoreOlderSessionsDate().toMSecsSinceEpoch()/1000; -#else - qint64 ignoreBefore = p_profile->session->ignoreOlderSessionsDate().toSecsSinceEpoch(); -#endif bool ignoreOldSessions = p_profile->session->ignoreOlderSessions(); for (auto & chunk : coalesced) { if (ignoreOldSessions && chunk->timestamp < ignoreBefore) { -#if QT_VERSION < QT_VERSION_CHECK(5,8,0) qWarning().noquote() << relativePath(chunk->m_path) << "skipping session" << chunk->sessionid << ":" << QDateTime::fromMSecsSinceEpoch(chunk->timestamp*1000).toString() << "older than" << QDateTime::fromMSecsSinceEpoch(ignoreBefore*1000).toString(); -#else - qWarning().noquote() << relativePath(chunk->m_path) << "skipping session" << chunk->sessionid << ":" - << QDateTime::fromSecsSinceEpoch(chunk->timestamp).toString() << "older than" - << QDateTime::fromSecsSinceEpoch(ignoreBefore).toString(); -#endif continue; } coalescedAndFiltered.append(chunk);