mobile/cleanup: use a mutex to protect storage access

Instead of the crude and error prone bool, let's just use the right tool
for this job.

In order to avoid issues with a goto across a mutex boundary, this
slightly restructures the code in one place - 'git show -w' makes it
clear that this is really rather simple in its changes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2020-03-28 18:14:00 -07:00
parent d482108f8c
commit d12e86cb2b
2 changed files with 43 additions and 45 deletions

View file

@ -9,6 +9,7 @@
#include <QElapsedTimer>
#include <QColor>
#include <QFile>
#include <QMutex>
#include "core/btdiscovery.h"
#include "core/gpslocation.h"
@ -255,7 +256,7 @@ private:
QString m_notificationText;
qreal m_lastDevicePixelRatio;
QElapsedTimer timer;
bool alreadySaving;
QMutex alreadySaving;
bool checkDate(const DiveObjectHelper &myDive, struct dive *d, QString date);
bool checkLocation(DiveSiteChange &change, const DiveObjectHelper &myDive, struct dive *d, QString location, QString gps);
bool checkDuration(const DiveObjectHelper &myDive, struct dive *d, QString duration);