From 823f814d85518d6f3f159f8db3e3d6805c6b04f4 Mon Sep 17 00:00:00 2001 From: edouard Date: Sun, 13 Mar 2011 22:27:26 +0000 Subject: [PATCH] OP-330 Log replay does not crash at the end anymore. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@3039 ebee16cc-31ac-478f-84a7-5cbb03baadba --- .../src/plugins/logging/logfile.cpp | 5 ++++- .../src/plugins/logging/logfile.h | 1 + .../src/plugins/logging/loggingplugin.cpp | 21 +++++++++---------- .../src/plugins/logging/loggingplugin.h | 4 ++-- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/logging/logfile.cpp b/ground/openpilotgcs/src/plugins/logging/logfile.cpp index 70df96c06..f02bce22a 100644 --- a/ground/openpilotgcs/src/plugins/logging/logfile.cpp +++ b/ground/openpilotgcs/src/plugins/logging/logfile.cpp @@ -44,6 +44,8 @@ bool LogFile::open(OpenMode mode) { void LogFile::close() { + emit aboutToClose(); + if (timer.isActive()) timer.stop(); file.close(); @@ -127,11 +129,12 @@ bool LogFile::startReplay() { file.read((char *) &lastTimeStamp,sizeof(lastTimeStamp)); timer.setInterval(10); timer.start(); + emit replayStarted(); return true; } bool LogFile::stopReplay() { - timer.stop(); + close(); emit replayFinished(); return true; } diff --git a/ground/openpilotgcs/src/plugins/logging/logfile.h b/ground/openpilotgcs/src/plugins/logging/logfile.h index f9e5216ab..861249e4a 100644 --- a/ground/openpilotgcs/src/plugins/logging/logfile.h +++ b/ground/openpilotgcs/src/plugins/logging/logfile.h @@ -36,6 +36,7 @@ protected slots: signals: void readReady(); + void replayStarted(); void replayFinished(); protected: diff --git a/ground/openpilotgcs/src/plugins/logging/loggingplugin.cpp b/ground/openpilotgcs/src/plugins/logging/loggingplugin.cpp index 92f1593cf..a4e31adb4 100644 --- a/ground/openpilotgcs/src/plugins/logging/loggingplugin.cpp +++ b/ground/openpilotgcs/src/plugins/logging/loggingplugin.cpp @@ -299,7 +299,6 @@ void LoggingThread::transactionCompleted(UAVObject* obj, bool success) LoggingPlugin::LoggingPlugin() : state(IDLE) { - // Do nothing logConnection = new LoggingConnection(); } @@ -347,6 +346,7 @@ bool LoggingPlugin::initialize(const QStringList& args, QString *errMsg) // Map signal from end of replay to replay stopped connect(getLogfile(),SIGNAL(replayFinished()), this, SLOT(replayStopped())); + connect(getLogfile(),SIGNAL(replayStarted()), this, SLOT(replayStarted())); return true; } @@ -428,23 +428,22 @@ void LoggingPlugin::loggingStopped() } /** - * Received the replay stoppedsignal from the LogFile + * Received the replay stopped signal from the LogFile */ void LoggingPlugin::replayStopped() { - Q_ASSERT(state == REPLAY); - - if(uavTalk) - delete(uavTalk); - - getLogfile()->close(); - - uavTalk = 0; state = IDLE; - emit stateChanged("IDLE"); } +/** + * Received the replay started signal from the LogFile + */ +void LoggingPlugin::replayStarted() +{ + state = REPLAY; + emit stateChanged("REPLAY"); +} diff --git a/ground/openpilotgcs/src/plugins/logging/loggingplugin.h b/ground/openpilotgcs/src/plugins/logging/loggingplugin.h index 5bc8059b4..7a5b797c1 100644 --- a/ground/openpilotgcs/src/plugins/logging/loggingplugin.h +++ b/ground/openpilotgcs/src/plugins/logging/loggingplugin.h @@ -137,14 +137,14 @@ protected: LoggingThread * loggingThread; // These are used for replay, logging in its own thread - UAVTalk * uavTalk; - LoggingConnection* logConnection; + LoggingConnection* logConnection; private slots: void toggleLogging(); void startLogging(QString file); void stopLogging(); void loggingStopped(); + void replayStarted(); void replayStopped(); private: