diff --git a/checkin_notes b/checkin_notes index fc4350dc85..12c2107a55 100644 --- a/checkin_notes +++ b/checkin_notes @@ -5680,3 +5680,12 @@ David 1 Aug 2010 sched/ sched_types.cpp + +Charlie 1 Aug 2010 + - MGR: Fix bugs saving and restoring info on which notices have been read: + saving as a double reduces precision, so save arrival time as string; + to avoid problems caused by rounding in save & restore operation, test in + reverse order (oldest first) and for arrival time <= dLastReadNoticeTime + + clientgui/ + MainDocument.cpp diff --git a/clientgui/MainDocument.cpp b/clientgui/MainDocument.cpp index 59efc19b90..9266d9f1d0 100644 --- a/clientgui/MainDocument.cpp +++ b/clientgui/MainDocument.cpp @@ -1823,16 +1823,19 @@ done: void CMainDocument::SaveUnreadNoticeInfo() { - wxString strBaseConfigLocation = wxString(wxT("/Notices/")); - wxConfigBase* pConfig = wxConfigBase::Get(FALSE); - wxString strDomainName = wxString(host.domain_name, wxConvUTF8, strlen(host.domain_name)); - wxString strArrivalTime = wxEmptyString; static double dLastSavedArrivalTime = 0.0; - pConfig->SetPath(strBaseConfigLocation + strDomainName); - if (dLastSavedArrivalTime != m_dLastReadNoticeArrivalTime) { - pConfig->Write(wxT("LastReadNoticeTime"), m_dLastReadNoticeArrivalTime); + wxString strBaseConfigLocation = wxString(wxT("/Notices/")); + wxConfigBase* pConfig = wxConfigBase::Get(FALSE); + wxString strDomainName = wxString(host.domain_name, wxConvUTF8, strlen(host.domain_name)); + wxString strArrivalTime = wxEmptyString; + + pConfig->SetPath(strBaseConfigLocation + strDomainName); + // wxConfigBase::Write(const wxString& key, double value) has + // insufficient precision so write a wxString. + strArrivalTime.Printf(wxT("%f"), m_dLastReadNoticeArrivalTime); + pConfig->Write(wxT("lastReadNoticeTime"), strArrivalTime); dLastSavedArrivalTime = m_dLastReadNoticeArrivalTime; } } @@ -1843,16 +1846,19 @@ void CMainDocument::RestoreUnreadNoticeInfo() { wxConfigBase* pConfig = wxConfigBase::Get(FALSE); wxString strDomainName = wxString(host.domain_name, wxConvUTF8, strlen(host.domain_name)); double dLastReadNoticeTime; + wxString strArrivalTime = wxEmptyString; int i, n = (int)notices.notices.size(); pConfig->SetPath(strBaseConfigLocation + strDomainName); - if (pConfig->Read(wxT("LastReadNoticeTime"), &dLastReadNoticeTime)) { - for (i=0; iarrival_time >= dLastReadNoticeTime) { + if (pConfig->Read(wxT("LastReadNoticeTime"), &strArrivalTime)) { + strArrivalTime.ToDouble(&dLastReadNoticeTime); + // To avoid problems caused by rounding in save & restore operation, test in + // reverse order (oldest first) and for arrival time <= dLastReadNoticeTime + for (i=n-1; i>=0; --i) { + if (notices.notices[i]->arrival_time <= dLastReadNoticeTime) { m_iLastReadNoticeSequenceNumber = notices.notices[i]->seqno; m_dLastReadNoticeArrivalTime = notices.notices[i]->arrival_time; - return; } } }