diff options
author | Arseniy-Movshev <dodoradio@outlook.com> | 2023-05-27 18:39:24 +0100 |
---|---|---|
committer | Arseniy-Movshev <dodoradio@outlook.com> | 2023-05-27 19:27:55 +0100 |
commit | 10693b321cc3cbeedb9262dc17282e86d9a13767 (patch) | |
tree | d813ab301db44611136192f5c70d2713e2fc8342 /qmlplugin | |
parent | df9b49d6123b83f0ce8239693bc1064de1a4e828 (diff) |
fix qml accessor:
- make sure that the reader doesn't create random files
- it is unclear why readwrite was used here in the first place, as readonly access is appropriate.
- make sure that `line` always has a value even if file is empty
Diffstat (limited to 'qmlplugin')
-rw-r--r-- | qmlplugin/stepsDataLoader.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/qmlplugin/stepsDataLoader.cpp b/qmlplugin/stepsDataLoader.cpp index 9d99c79..cf072c3 100644 --- a/qmlplugin/stepsDataLoader.cpp +++ b/qmlplugin/stepsDataLoader.cpp @@ -27,12 +27,12 @@ int StepsDataLoader::getTodayData() { int StepsDataLoader::getDataForDate(QDate date) { // This is obvious garbage. This should really be abstracted and cached, so that every page doesn't have to reload the file from scratch. // The intention is to also add graph functionality at some point. The graph will be simplifying the data before loading it in - it would be worth caching the simplified data when it comes to that as well. QFile file(fileNameForDate(date, "stepCounter")); - if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) { + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { qDebug() << "failed to open file"; return 0; } QTextStream inStream(&file); - QString line; + QString line = "0"; int i; while(!inStream.atEnd()) { |