From 0c1fbf4cf75598bbeaf54fcadeb1dca14f83d379 Mon Sep 17 00:00:00 2001 From: Constantin Shalnev Date: Tue, 8 Dec 2015 12:49:00 +0300 Subject: [PATCH] Fixed notes --- map/gps_track.cpp | 16 +++++++++------- map/gps_track.hpp | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/map/gps_track.cpp b/map/gps_track.cpp index 365f289fc9..13e103ca7f 100644 --- a/map/gps_track.cpp +++ b/map/gps_track.cpp @@ -30,7 +30,7 @@ void GpsTrack::AddPoint(location::GpsTrackInfo const & info) { lock_guard lg(m_guard); - InitFile(); + LazyInitFile(); // Write point to the file. // If file exception happens, then drop file. @@ -73,7 +73,7 @@ void GpsTrack::AddPoints(vector const & points) lock_guard lg(m_guard); - InitFile(); + LazyInitFile(); // Write point to the file. // If file exception happens, then drop file. @@ -127,7 +127,7 @@ void GpsTrack::Clear() { lock_guard lg(m_guard); - InitFile(); + LazyInitFile(); if (m_file) { @@ -190,12 +190,12 @@ void GpsTrack::SetCallback(TGpsTrackDiffCallback callback) if (!callback) return; - InitCollection(); + LazyInitCollection(); SendInitialSnapshot(); } -void GpsTrack::InitFile() +void GpsTrack::LazyInitFile() { // Must be called under m_guard lock @@ -250,7 +250,7 @@ void GpsTrack::InitFile() } } -void GpsTrack::InitCollection() +void GpsTrack::LazyInitCollection() { // Must be called under m_guard lock @@ -259,7 +259,7 @@ void GpsTrack::InitCollection() m_collection = make_unique(kGpsCollectionMaxItemCount, m_duration); - InitFile(); + LazyInitFile(); if (!m_file) return; @@ -292,6 +292,8 @@ void GpsTrack::InitCollection() void GpsTrack::SendInitialSnapshot() { + // Must be called under m_guard lock + if (!m_callback) return; diff --git a/map/gps_track.hpp b/map/gps_track.hpp index febfb252c4..bcc52a10ce 100644 --- a/map/gps_track.hpp +++ b/map/gps_track.hpp @@ -43,8 +43,8 @@ public: void SetCallback(TGpsTrackDiffCallback callback); private: - void InitFile(); - void InitCollection(); + void LazyInitFile(); + void LazyInitCollection(); void SendInitialSnapshot(); string const m_filePath;