From 71c05c46257d15f864fa7659281db3d57eda17c2 Mon Sep 17 00:00:00 2001 From: sawinglogz <3787776-sawinglogz@users.noreply.gitlab.com> Date: Tue, 7 May 2019 16:50:58 -0400 Subject: [PATCH 1/6] Change the current working directory instead of using --work-dir. It was previously working in a false-positive state, where it would behave as expected if you ran "make" from within a subdirectory of the git repo. If you ran make anywhere else, at least diff-index would break. --- oscar/update_gitinfo.bat | 7 ++++--- oscar/update_gitinfo.sh | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/oscar/update_gitinfo.bat b/oscar/update_gitinfo.bat index 9ffd20b8..dee9e797 100755 --- a/oscar/update_gitinfo.bat +++ b/oscar/update_gitinfo.bat @@ -1,10 +1,11 @@ @echo off setlocal set DIR=%~dp0 +cd %DIR% -for /f %%i in ('git --work-tree %DIR% rev-parse --abbrev-ref HEAD') do set GIT_BRANCH=%%i -for /f %%i in ('git --work-tree %DIR% rev-parse --short HEAD') do set GIT_REVISION=%%i -git --work-tree %DIR% diff-index --quiet HEAD || set GIT_REVISION=%GIT_REVISION%+ +for /f %%i in ('git rev-parse --abbrev-ref HEAD') do set GIT_BRANCH=%%i +for /f %%i in ('git rev-parse --short HEAD') do set GIT_REVISION=%%i +git diff-index --quiet HEAD -- || set GIT_REVISION=%GIT_REVISION%+ if "%GIT_BRANCH"=="" set GIT_BRANCH="Unknown" if "%GIT_REVISION"=="" set GIT_REVISION="Unknown" diff --git a/oscar/update_gitinfo.sh b/oscar/update_gitinfo.sh index 909ac299..daaab8fb 100755 --- a/oscar/update_gitinfo.sh +++ b/oscar/update_gitinfo.sh @@ -3,9 +3,9 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $DIR -GIT_BRANCH=`git --work-tree $DIR rev-parse --abbrev-ref HEAD` -GIT_REVISION=`git --work-tree $DIR rev-parse --short HEAD` -$(git --work-tree $DIR diff-index --quiet HEAD) +GIT_BRANCH=`git rev-parse --abbrev-ref HEAD` +GIT_REVISION=`git rev-parse --short HEAD` +$(git diff-index --quiet HEAD --) if [ $? -ne 0 ]; then GIT_REVISION="$GIT_REVISION+" # uncommitted changes fi From 609e02b2c5321de49a3e09b3a5ea0e46bd65af66 Mon Sep 17 00:00:00 2001 From: sawinglogz <3787776-sawinglogz@users.noreply.gitlab.com> Date: Wed, 8 May 2019 12:01:06 -0400 Subject: [PATCH 2/6] Fix to update_gitinfo.bat from Guy for the case where no git_info.h exists yet. --- oscar/update_gitinfo.bat | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/oscar/update_gitinfo.bat b/oscar/update_gitinfo.bat index dee9e797..3ae5665a 100755 --- a/oscar/update_gitinfo.bat +++ b/oscar/update_gitinfo.bat @@ -14,10 +14,11 @@ echo // This is an auto generated file > %DIR%git_info.new echo const QString GIT_BRANCH="%GIT_BRANCH%"; >> %DIR%git_info.new echo const QString GIT_REVISION="%GIT_REVISION%"; >> %DIR%git_info.new -fc %DIR%git_info.h %DIR%git_info.new > nul -if errorlevel 0 ( - del /q %DIR%git_info.new -) else ( - echo Updating %DIR%git_info.h - move /y %DIR%git_info.new %DIR%git_info.h -) +fc %DIR%git_info.h %DIR%git_info.new >nul 2>nul && del /q %DIR%git_info.new || goto NewFile +goto AllDone + +:NewFile +echo Updating %DIR%git_info.h +move /y %DIR%git_info.new %DIR%git_info.h + +:AllDone From e67aae78cf662c0e28e59743a89f74dde4807876 Mon Sep 17 00:00:00 2001 From: sawinglogz <3787776-sawinglogz@users.noreply.gitlab.com> Date: Wed, 8 May 2019 17:06:17 -0400 Subject: [PATCH 3/6] Make warnings fail regression tests, fix warnings. --- oscar/Graphs/gSessionTimesChart.cpp | 3 ++- oscar/SleepLib/common.cpp | 3 ++- oscar/daily.cpp | 8 ++++---- oscar/oscar.pro | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/oscar/Graphs/gSessionTimesChart.cpp b/oscar/Graphs/gSessionTimesChart.cpp index 579614b9..d3a38cf9 100644 --- a/oscar/Graphs/gSessionTimesChart.cpp +++ b/oscar/Graphs/gSessionTimesChart.cpp @@ -1142,7 +1142,8 @@ void gAHIChart::customCalc(Day *day, QVector &list) case 1: calc->wavg_sum += value; calc->divisor += hours; - default: + break; + case 2: calc->avg_sum += value; calc->cnt++; break; diff --git a/oscar/SleepLib/common.cpp b/oscar/SleepLib/common.cpp index 65769d0b..1069ea22 100644 --- a/oscar/SleepLib/common.cpp +++ b/oscar/SleepLib/common.cpp @@ -802,7 +802,8 @@ QByteArray gUncompress(const QByteArray & data) switch (ret) { case Z_NEED_DICT: - ret = Z_DATA_ERROR; // and fall through + ret = Z_DATA_ERROR; + // fall through case Z_DATA_ERROR: case Z_MEM_ERROR: Q_UNUSED(ret) diff --git a/oscar/daily.cpp b/oscar/daily.cpp index 480a1a10..0d4cb1ae 100644 --- a/oscar/daily.cpp +++ b/oscar/daily.cpp @@ -2350,10 +2350,10 @@ void Daily::updateCube() } -void Daily::on_toggleGraphs_clicked(bool checked) +void Daily::on_toggleGraphs_clicked(bool /*checked*/) { QString s; - QIcon *icon=checked ? icon_off : icon_on; + //QIcon *icon=checked ? icon_off : icon_on; if (ui->graphCombo == nullptr ) qDebug() << "ToggleGraphs clicked with null graphCombo ptr"; else @@ -2414,10 +2414,10 @@ void Daily::on_eventsCombo_activated(int index) GraphView->redraw(); } -void Daily::on_toggleEvents_clicked(bool checked) +void Daily::on_toggleEvents_clicked(bool /*checked*/) { QString s; - QIcon *icon=checked ? icon_on : icon_off; + //QIcon *icon=checked ? icon_on : icon_off; if (ui->toggleEvents == nullptr ) qDebug() << "ToggleEvents clicked with null toggleEvents ptr"; diff --git a/oscar/oscar.pro b/oscar/oscar.pro index a4476e5c..a6410d1f 100644 --- a/oscar/oscar.pro +++ b/oscar/oscar.pro @@ -443,8 +443,8 @@ test { CONFIG += console debug CONFIG -= app_bundle !win32 { # add memory checking on Linux and macOS test builds - QMAKE_CFLAGS += -fsanitize=address -fno-omit-frame-pointer -fno-common -fsanitize-address-use-after-scope - QMAKE_CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -fno-common -fsanitize-address-use-after-scope + QMAKE_CFLAGS += -Werror -fsanitize=address -fno-omit-frame-pointer -fno-common -fsanitize-address-use-after-scope + QMAKE_CXXFLAGS += -Werror -fsanitize=address -fno-omit-frame-pointer -fno-common -fsanitize-address-use-after-scope QMAKE_LFLAGS += -fsanitize=address } From 6e6bc81be8c68561f14bdfdfb22a38067487e801 Mon Sep 17 00:00:00 2001 From: sawinglogz <3787776-sawinglogz@users.noreply.gitlab.com> Date: Wed, 8 May 2019 17:08:12 -0400 Subject: [PATCH 4/6] Fix session averaging bug discovered when fixing warning. May fix #59. --- oscar/Graphs/gSessionTimesChart.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oscar/Graphs/gSessionTimesChart.cpp b/oscar/Graphs/gSessionTimesChart.cpp index d3a38cf9..14004373 100644 --- a/oscar/Graphs/gSessionTimesChart.cpp +++ b/oscar/Graphs/gSessionTimesChart.cpp @@ -1074,8 +1074,8 @@ void gTTIAChart::afterDraw(QPainter &, gGraph &graph, QRectF rect) } break; case 2: - if (calc.divisor > 0) { - mid = calc.avg_sum / calc.divisor; + if (calc.cnt > 0) { + mid = calc.avg_sum / calc.cnt; } break; } From e47660e15aa4ebaa2eec909f33e3cf73a5dd4419 Mon Sep 17 00:00:00 2001 From: sawinglogz <3787776-sawinglogz@users.noreply.gitlab.com> Date: Wed, 8 May 2019 17:09:15 -0400 Subject: [PATCH 5/6] Disable broken "ignore" setting for PRS1. Fixes #73. --- oscar/SleepLib/loader_plugins/prs1_loader.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/oscar/SleepLib/loader_plugins/prs1_loader.cpp b/oscar/SleepLib/loader_plugins/prs1_loader.cpp index e44f89f4..5065bcff 100644 --- a/oscar/SleepLib/loader_plugins/prs1_loader.cpp +++ b/oscar/SleepLib/loader_plugins/prs1_loader.cpp @@ -692,8 +692,10 @@ void PRS1Loader::ScanFiles(const QStringList & paths, int sessionid_base, Machin QDateTime datetime; + /* Unused until we get an actual timestamp below. QDateTime ignoreBefore = p_profile->session->ignoreOlderSessionsDate(); bool ignoreOldSessions = p_profile->session->ignoreOlderSessions(); + */ // for each p0/p1/p2/etc... folder for (int p=0; p < size; ++p) { @@ -723,12 +725,14 @@ void PRS1Loader::ScanFiles(const QStringList & paths, int sessionid_base, Machin continue; } + /* This never worked: the filename isn't a timestamp. if (ignoreOldSessions) { datetime = QDateTime::fromTime_t(sid); if (datetime < ignoreBefore) { continue; } } + */ if (m->SessionExists(sid)) { From fb29ce022259eb672e8201d97caf868585c40ff3 Mon Sep 17 00:00:00 2001 From: sawinglogz <3787776-sawinglogz@users.noreply.gitlab.com> Date: Wed, 8 May 2019 17:18:00 -0400 Subject: [PATCH 6/6] Fix one more warning. setChecked() only takes a boolean, Qt::Checked/Unchecked are only used for tri-state checkboxes. --- oscar/daily.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oscar/daily.cpp b/oscar/daily.cpp index 0d4cb1ae..0866b908 100644 --- a/oscar/daily.cpp +++ b/oscar/daily.cpp @@ -424,7 +424,7 @@ Daily::Daily(QWidget *parent,gGraphView * shared) GraphView->setEmptyText(STR_Empty_NoData); previous_date=QDate(); - ui->calButton->setChecked(AppSetting->calendarVisible() ? Qt::Checked : Qt::Unchecked); + ui->calButton->setChecked(AppSetting->calendarVisible() ? true : false); on_calButton_toggled(AppSetting->calendarVisible()); GraphView->resetLayout();