Commit 0d4850b5 authored by Christian Rüb's avatar Christian Rüb
Browse files

flush log at least every 5min

parent 79a343e3
......@@ -4,6 +4,9 @@
GPSFileWriter::GPSFileWriter(QObject *parent) : QObject(parent) {
started = false;
logFile = NULL;
timer = new QTimer(this);
timer->setInterval(300000);
connect(timer, SIGNAL(timeout()), this, SLOT(flushLog()));
}
bool GPSFileWriter::setFile(QString filename) {
......@@ -38,9 +41,11 @@ void GPSFileWriter::startLog() {
started = false;
return;
}
timer->start();
}
void GPSFileWriter::stopLog() {
timer->stop();
logFile->close();
started = false;
return;
......@@ -61,3 +66,9 @@ void GPSFileWriter::writeEntry(GPSPosition gpsPosition, GPSAccuracy gpsAccuracy,
}
}
}
void GPSFileWriter::flushLog() {
if(logFile && started) {
logFile->flush();
}
}
......@@ -5,6 +5,7 @@
#include <QFile>
#include "gps.h"
#include <QDebug>
#include <QTimer>
class GPSFileWriter : public QObject {
Q_OBJECT
......@@ -15,12 +16,14 @@ public:
private:
bool started;
QFile* logFile;
QTimer* timer;
public slots:
bool setFile(QString);
void startLog();
void stopLog();
void writeEntry(GPSPosition,GPSAccuracy,int);
void flushLog();
signals:
void writerError(QString);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment