From 172322316537049f6ced59877a3b5bd3d2f64f2c Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Thu, 29 Dec 2016 19:54:27 +0000 Subject: [PATCH] XCCalendarList: Look at internal_updatedata checksum before updating controls --- source/widgets/XCCalendarList.cpp | 26 +++++++++++++++++++++++++- source/widgets/XCCalendarList.h | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/source/widgets/XCCalendarList.cpp b/source/widgets/XCCalendarList.cpp index 62efb9c..6fc7f7a 100644 --- a/source/widgets/XCCalendarList.cpp +++ b/source/widgets/XCCalendarList.cpp @@ -44,7 +44,27 @@ XCCalendarList::~XCCalendarList(){ void XCCalendarList::UpdateCalendarList(CalendarDataStorage *dataStorage){ - // TODO: Verify if the generated code has changed. + // Verify if the generated code has changed. Return if not. + + CDSGetChecksumResult currentChecksum = dataStorage->GetChecksum("internal_updatedata"); + + if (checksumUpdate == currentChecksum.checksumValue){ + + // Checksum matches so return. + return; + + } + + // TODO: Delete the old controls. + + for (vector::iterator accountCtrlIter = accountControlList.begin(); + accountCtrlIter != accountControlList.end(); accountCtrlIter++){ + + delete *accountCtrlIter; + + } + + accountControlList.clear(); // Get the list of accounts and create them one by one. @@ -78,4 +98,8 @@ void XCCalendarList::UpdateCalendarList(CalendarDataStorage *dataStorage){ } + // Set the updated checksum. + + checksumUpdate = currentChecksum.checksumValue; + } \ No newline at end of file diff --git a/source/widgets/XCCalendarList.h b/source/widgets/XCCalendarList.h index 7dbb093..e05f697 100644 --- a/source/widgets/XCCalendarList.h +++ b/source/widgets/XCCalendarList.h @@ -41,8 +41,8 @@ class XCCalendarList: public wxPopupTransientWindow wxScrolledWindow *scwMain = nullptr; wxBoxSizer *szrScrolled = nullptr; std::vector accountControlList; + std::string checksumUpdate = ""; protected: - public: XCCalendarList(wxWindow *parent); void UpdateCalendarList(CalendarDataStorage *dataStorage); -- 2.39.2